WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] How to display a list of the products of the current category? (2 posts)

  1. alezander
    Member
    Posted 11 months ago #

    Hello

    My structure of products is as follows:

    Notebooks (category)
    --Samsung (subcategory)
    ---- Product1
    ---- Product2
    ---- Product3
    --Asus (subcategory)
    ---- Product4
    ---- Product5
    Smartphones (category)
    --Samsung (subcategory)
    ---- Product6
    ---- Product7

    How to determine a product category and subcategory, and then display a list of all the products of the current subcategory with product name, price and permalink?

    Now, I am printing the entire list of products with the following code.
    But I do not understand how to limit its current sub-category.

    $ordering_args = $woocommerce->query->get_catalog_ordering_args( $orderby, $order );

    $args = array
    ('post_type'=> 'product',
    'post_status' => 'publish',
    'ignore_sticky_posts' => 1,
    'orderby' => $ordering_args['orderby'],
    'order' => $ordering_args['order'],
    'meta_query'=> array (
    array
    (
    'key'=> '_visibility',
    'value' => array('catalog', 'visible'),
    'compare' => 'IN'
    )
    ),
    'tax_query' => array(
    array
    (
    'taxonomy' => 'product_cat',
    'terms' => array( esc_attr($category) ),
    'field' => 'slug',
    'operator' => 'IN'
    )
    )
    );

    ob_start();
    $products = new WP_Query( $args );

    if ( $products->have_posts() ) : ?>

    <?php //woocommerce_product_loop_start(); ?>

    <?php //woocommerce_product_loop_end(); ?>

    endif;

    http://wordpress.org/plugins/woocommerce/

  2. alezander
    Member
    Posted 11 months ago #

    function widget at the class-wc-widget-product-categories.php and wp_list_categories( apply_filters( 'woocommerce_product_categories_widget_args', $cat_args ) ); - all I need to solve this problem

Reply

You must log in to post.

About this Plugin

About this Topic