Hide out of stock from related products
-
I would like to
hide Out of Stock
products from Related products in single product pages. Is it possible?
I found this snippet but it didn’t work out!add_filter( 'woocommerce_product_related_posts_query', 'alter_product_related_posts_query', 10, 3 ); function alter_product_related_posts_query( $query, $product_id, $args ){ global $wpdb; $query['join'] .= " INNER JOIN {$wpdb->postmeta} as pm ON p.ID = pm.post_id "; $query['where'] .= " AND pm.meta_key = '_stock_status' AND meta_value = 'instock' "; return $query; }
Any track is appreciated.
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘Hide out of stock from related products’ is closed to new replies.