WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
How to list only grouped products in WooCommerce's categories (3 posts)

  1. Machi
    Member
    Posted 11 months ago #

    Hello,
    we are using a WooCommerce plugin with grouped products on our website. Basically we have one "parent" - grouped product and its variations are listed as a simple "standalone" product. It is automatically imported so we are unable to import it as variations which should theoretically solve the problem.

    The only issue is that WooCommerce displays all products in category listing, grouped products together with simple products. Is there please a way how to list just grouped products in these listing? See a sample please: http://rkbtechnika.cz/kategorie-produktu/kim-tec/servisni-chemie/cistici-pripravky/

    Thanks a lot, Jakub

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

  2. Zafi
    Member
    Posted 6 months ago #

    Hi Machi

    Did you manage to get this sorted, I have same requirement.

  3. andreybs11
    Member
    Posted 4 months ago #

    Hi,

    Add the below snippet inside your functions.php file

    function filter_grouped_products( $query ) {
      if ( !is_admin() && is_shop() && $query->is_main_query() ) {
        $query->set('post_type', 'product');
        $product_type = array(
          'taxonomy' => 'product_type',
          'field' => 'slug',
          'terms' => 'grouped'
        );
        $query->set('tax_query', array($product_type) );
      }
    }
    add_action('pre_get_posts', 'filter_grouped_products');

    Regards

Reply

You must log in to post.

About this Plugin

About this Topic