Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'woocommerce_product_query_meta_query', 'shop_only_instock_products', 10, 2 );
- function shop_only_instock_products( $meta_query, $query ) {
- if( is_admin() ) return $meta_query;
- $meta_query['relation'] = 'OR';
- $meta_query[] = array(
- 'key' => '_price',
- 'value' => '',
- 'type' => 'numeric',
- 'compare' => '!='
- );
- $meta_query[] = array(
- 'key' => '_price',
- 'value' => 0,
- 'type' => 'numeric',
- 'compare' => '!='
- );
- return $meta_query;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement