Каталог

term_id; } $exclude_term = get_term_by('name', 'Misc', 'product_cat'); $exclude_id = $exclude_term ? $exclude_term->term_id : 0; $args = array( 'taxonomy' => 'product_cat', 'hide_empty' => false, 'parent' => $parent_id, 'exclude' => array($exclude_id), 'orderby' => 'menu_order', 'order' => 'ASC', ); $categories = get_terms($args); foreach ($categories as $category) { $children = get_terms(array( 'taxonomy' => 'product_cat', 'hide_empty' => false, 'parent' => $category->term_id, )); $has_children = !empty($children); $is_active = ($category->term_id == $current_cat_id) || term_is_ancestor_of($category->term_id, $current_cat_id, 'product_cat'); echo '
'; echo ''; if ($has_children) { echo '
'; foreach ($children as $child) { $grandchildren = get_terms(array( 'taxonomy' => 'product_cat', 'hide_empty' => false, 'parent' => $child->term_id, )); $has_grandchildren = !empty($grandchildren); $is_child_active = ($child->term_id == $current_cat_id) || term_is_ancestor_of($child->term_id, $current_cat_id, 'product_cat'); echo '
'; echo '
'; echo '' . esc_html($child->name) . ''; if ($has_grandchildren) { echo ''; } echo '
'; if ($has_grandchildren) { echo '
'; foreach ($grandchildren as $grandchild) { $is_grand_active = $grandchild->term_id == $current_cat_id; echo ''; echo esc_html($grandchild->name) . ''; } echo '
'; } echo '
'; } echo '
'; } echo '
'; } } ?>
term_id ) ) { $child_categories = get_terms(array( 'taxonomy' => 'product_cat', 'parent' => $current_category->term_id, 'hide_empty' => false, )); } if ( !empty($child_categories) ) { // Только подкатегории, без товаров в этой категории ?>

term_id, 'thumbnail_id', true); $image_url = wp_get_attachment_url($thumbnail_id); $description = term_description($child_category->term_id, 'product_cat'); echo '
'; if($image_url) { echo ''; echo '' . esc_attr($child_category->name) . ''; echo ''; } echo '
'; echo '' . esc_html($child_category->name) . ''; if($description) { echo '

' . $description . '

'; } echo 'Перейти в раздел'; echo '
'; echo '
'; } ?>

'; woocommerce_product_loop_start(); if (wc_get_loop_prop('total')) { while (have_posts()) { the_post(); wc_get_template_part('content', 'product'); } } woocommerce_product_loop_end(); echo '
'; echo '
'; $current_per_page = isset($_GET['per_page']) ? sanitize_text_field($_GET['per_page']) : '12'; $current_label = ($current_per_page === 'all') ? 'Все' : intval($current_per_page); $check_svg = ''; $per_page_options = array('12', '24', '48', 'all'); $per_page_labels = array('12' => '12', '24' => '24', '48' => '48', 'all' => 'Все'); echo '

Количество товаров на странице:

'; echo ''; echo '
'; foreach ($per_page_options as $opt) { $is_active = ($opt === $current_per_page) ? ' active' : ''; echo ''; } echo '
'; echo '
'; echo '
'; the_posts_pagination(array( 'prev_text' => '', // SVG для стрелки назад 'next_text' => '', // SVG для стрелки вперед 'before_page_number' => '', 'after_page_number' => '', )); echo '
'; global $wp_query; $total_products = $wp_query->found_posts; echo '

' . $wp_query->post_count . ' товаров из ' . $total_products . '

'; echo '
'; // Счетчик товаров echo '
'; do_action('woocommerce_after_shop_loop'); } else { do_action('woocommerce_no_products_found'); } ?>

Продукция

'product_cat', 'parent' => 0, 'hide_empty' => false, ]); if (!empty($categories) && !is_wp_error($categories)) { foreach ($categories as $category) { if ($category->name === 'Misc') { continue; } $thumb_id = get_term_meta($category->term_id, 'thumbnail_id', true); $thumb_url = $thumb_id ? wp_get_attachment_image_url($thumb_id, 'full') : '/wp-content/uploads/woocommerce-placeholder.png'; $term_link = get_term_link($category); ?>