WordPress.org

Forums

The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

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

  1. Machi
    Member
    Posted 3 years 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 2 years ago #

    Hi Machi

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

  3. andreybs11
    Member
    Posted 2 years 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

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic