WooCommerce shortcode
-
Hello,
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) { add_filter('posts_clauses', 'order_by_stock_status', 2000); } function order_by_stock_status($posts_clauses) { global $wpdb; if (is_woocommerce() && (is_shop() || is_product_category() || is_product_tag())) { $posts_clauses['join'] .= " INNER JOIN $wpdb->postmeta istockstatus ON ($wpdb->posts.ID = istockstatus.post_id) "; $posts_clauses['orderby'] = " istockstatus.meta_value ASC, " . $posts_clauses['orderby']; $posts_clauses['where'] = " AND istockstatus.meta_key = '_stock_status' AND istockstatus.meta_value <> '' " . $posts_clauses['where']; } return $posts_clauses; }
i am using the above code to display out of stock products at the bottom of the page on my website, this code works perfectly on my shop page however does not work on pages where i use this shortcode to display products: [products limit=”8″ columns=”4″ orderby=”date” category=”zara men perfumes” cat_operator=”IN”].
I would like to modify this shortcode to also show instock products first, or only show instock products. Thanks.
The page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘WooCommerce shortcode’ is closed to new replies.