PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Excluding Listings from search bar

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hi,

I've just had your plugin installed on my site which is a WooCommerce Dokan Multivendor site with Listeo theme. I therefore have actual products (Wordpress > Products > Simple products) and Listings (Wordpress > Products > Listing Bookings). I have search by text on, but I only want to have 'Simple products' in the results and exclude 'Listing Bookings'. How do I exclude listings from the results please?

Hello Frankie

If I undertood you rigth here is the code you need (place it in file functions.php of the current wp theme):

add_filter('woof_products_query', function($query) {
    if (!isset($_REQUEST['woof_text'])) { return $query; }

    $tax_query = $query->get('tax_query');
    if (!is_array($tax_query)) {
        $tax_query = array();
    }
    
    $tax_query[] = array(
        'taxonomy' => 'product_type',
        'field'    => 'slug',
        'terms'    => 'simple',
        'operator' => 'IN'
    );
    
    $query->set('tax_query', $tax_query);
    
    return $query;
}, 10);

 

This code allows to cut all products in search results exept products of type 'simple'