Hide woocommerce zero price in related products
-
Hi, I have WOO ?7.3.0 ver. I have many products with zero price…. for some reason I cant delete/draft it. I need just hide it from frontend. I do this:
function hide_zero_price_products( $query ) { if ( is_woocommerce() && $query->is_main_query() ) { $query->set( 'meta_query', array( array( 'key' => '_regular_price', 'compare' => '>', 'value' => 0, ), ) ); } }
But I steel see zero price product in woocommerce_related_products widget
I try many code variations…. but cant hide zero price products from this widget:
add_filter( 'woocommerce_related_products_args', function( $args ) { unset( $args['post__in'] ); $args['meta_query'] = array( 'key' => '_regular_price', 'compare' => '>', 'value' => 0, ); return $args; }); and add_action( 'woocommerce_product_query', 'themelocation_product_query' ); function themelocation_product_query( $q ){ $meta_query = $q->get( 'meta_query' ); $meta_query[] = array( 'key' => '_regular_price', 'value' => 0, 'compare' => '>' ); $q->set( 'meta_query', $meta_query ); }
Any tips?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Hide woocommerce zero price in related products’ is closed to new replies.