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

Product filter showing empty Term with Condition in "woocommerce_product_query"

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,

We use custom Condition through"woocommerce_product_query" to show some particular SKUs. But it makes the Empty Terms Show too.

Can you please Guide me on how can I add my"woocommerce_product_query" Condition within the plugin, so that Empty terms hide?

Awaiting your reply.

Best Wishes.

I used the following Code too but still getting empty Terms.

add_action( 'woof_products_query', 'woof_wheel_pre_get_posts_query' );
function woof_wheel_pre_get_posts_query($query) {
/* Wheels SKU Search START */

$vehicle=$_GET['vehicle'];
if(isset($vehicle)&&($vehicle=='wheels'||$vehicle=='both')){

$wheel_staggered=$_GET['wheel-staggered'];
$cyear=$_GET['cyear'];
$make=$_GET['make2'];
$model=$_GET['model'];
$trim=$_GET['trim'];
$trimoption=$_GET['trimoption'];
$wheeldiameter=$_GET['wheel-size'];
$vehicle_info = get_atdproductnumber_by_vehicle_wheels($cyear,$make,$model,$trim,$trimoption,$wheeldiameter);
$fitmentresults = $vehicle_info['fitments'][0]['fitmentresults'];
$fitmentitems=$fitmentfront=$fitmentback=$fitmentboth=array();
foreach($fitmentresults as $fitmentresult){
$front_item=$rear_item="";
$fronts = $fitmentresult['position']['front']['products'];
foreach($fronts as $front){
$front_item=$front['atdproductnumber'];
$fitmentfront[]=$front_item;
}
$backs = $fitmentresult['position']['rear']['products'];
foreach($backs as $back){
$rear_item=$back['atdproductnumber'];
$fitmentback[]=$rear_item;
}

$fitmentitems[$front_item]=$rear_item;
$boths = $fitmentresult['position']['both']['products'];
foreach($boths as $both){
$fitmentboth[]=$both['atdproductnumber'];
}

}

if(isset($wheel_staggered)&&$wheel_staggered=="1"){
$products_sku=$fitmentfront;
}else{
$products_sku=$fitmentboth;
}

if(empty($products_sku))
$products_sku[]=0;

$query['meta_query'][] = array(
'key' => '_sku',
'value' => $products_sku,
'compare' => 'IN'
);
}

/* Wheels SKU Search END */
return $query;

}

Hello

You can try  this  code: https://products-filter.com/manipulate-search-data-options