Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * Best way to remove out of stack products from related products
- */
- add_filter('woocommerce_product_related_posts_query','aah_product_related_posts_query', 10, 2);
- function aah_product_related_posts_query( $query, $product_id ) {
- global $wpdb;
- $query['join'] .= " LEFT JOIN wp_postmeta ON ( p.ID = wp_postmeta.post_id )";
- $query['where'] .= " AND ( wp_postmeta.meta_key = '_stock_status' AND wp_postmeta.meta_value = 'instock' )";
- return $query;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement