Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. add_filter( 'woocommerce_product_query_meta_query', 'shop_only_instock_products', 10, 2 );
  2. function shop_only_instock_products( $meta_query, $query ) {
  3.  
  4.  
  5. if( is_admin() ) return $meta_query;
  6.  
  7. $meta_query['relation'] = 'OR';
  8.  
  9. $meta_query[] = array(
  10. 'key' => '_price',
  11. 'value' => '',
  12. 'type' => 'numeric',
  13. 'compare' => '!='
  14. );
  15. $meta_query[] = array(
  16. 'key' => '_price',
  17. 'value' => 0,
  18. 'type' => 'numeric',
  19. 'compare' => '!='
  20. );
  21. return $meta_query;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement