Exclude Out Of Stock Items From [Product} Shortcode
-
I want to display certain products on a page but only in stock items. There seems to be some examples of adding an additional filter via PHP to do this but I can’t figure out how to implement the code (do I need to add an extra argument in my shortcake or does the PHP work site wide?
Code…
add_filter( 'woocommerce_shortcode_products_query', function( $query_args, $atts, $loop_name ){ if( $loop_name == 'product_category' ){ $query_args['meta_query'] = array( array( 'key' => '_stock_status', 'value' => 'outofstock', 'compare' => 'NOT LIKE', ) ); } return $query_args; }, 10, 3);
This seems like it should be the easiest thing to do but I’m stumped
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Exclude Out Of Stock Items From [Product} Shortcode’ is closed to new replies.