• Resolved AlexF

    (@alexfreelance)


    Hello! Can you tell me how to exclude a certain product category? Products from it should not fall into the filter.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Nick McReynolds

    (@woobewoo)

    Hello @alexfreelance,

    https://prnt.sc/RUopkA-mlEVx – You can exclude the desired category by ID in the Categories filter settings: https://woobewoo.com/documentation/product-categories/

    Thread Starter AlexF

    (@alexfreelance)

    ok, I added the sorting of categories, specified the category id in the exceptions, but still the products fall into the general list of products

    Thread Starter AlexF

    (@alexfreelance)

    Here is the code that removes the selected category from the list of products. I need the same thing from the plugin. If it helps.

    function exclude_category_for_guests($query)
    {
      if (! is_admin() && $query->is_main_query() && (is_shop() || is_product_category() || is_product())) {
        if (! is_user_logged_in()) {
          $tax_query = $query->get('tax_query');
          if (! empty($tax_query)) {
            $tax_query[] = array(
              'taxonomy' => 'product_cat',
              'field'    => 'slug',
              'terms'    => 'selected_category',
              'operator' => 'NOT IN',
            );
          } else {
            $tax_query = array(
              array(
                'taxonomy' => 'product_cat',
                'field'    => 'slug',
                'terms'    => 'selected_category',
                'operator' => 'NOT IN',
              ),
            );
          }
          $query->set('tax_query', $tax_query);
        }
      }
    }
    add_action('pre_get_posts', 'exclude_category_for_guests');
    Thread Starter AlexF

    (@alexfreelance)

    Any ideas?

    Plugin Author Nick McReynolds

    (@woobewoo)

    Hi @alexfreelance,

    Please contact our internal support team
    https://woobewoo.com/contact-us/

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.