Digital experiences for all disciplines
New Landing › How can we help? › Atelier › Out of Stock product to displayed at the end
New Landing › How can we help? › Atelier › Out of Stock product to displayed at the end
- This topic has 14 replies, 4 voices, and was last updated 7 years by Rui Guerreiro – SUPPORT.
-
Posted in: Atelier
-
February 24, 2017 at 3:42 pm #315051
Hi,
I have some out of stock products, that are displayed on product category pages in between in stock products.
I want Out of Stock products to either not appear on product category pages or in the end of the pages when all the in stock products have been displayed.
Please advise with a solution.
Thanks
February 24, 2017 at 7:21 pm #315103Hi,
The only that is possible is to hide the out of stock products.
Can you give us an example category page where you have some of the out of stock products?-Rui
February 25, 2017 at 7:27 am #315120Hi,
Below is a category page with Out of Stock Products
https://mydhaba.in/product-category/food-and-beverages/edible-oils/
Please suggest a solution.
Thanks
February 27, 2017 at 3:15 pm #315280You can hide those using:
.tax-product_cat li.outofstock { display: none; }
February 27, 2017 at 5:02 pm #315311Hi,
Thanks, this is working as expected for category pages.
Can we also hide them from the related products list shown on product page ?
February 27, 2017 at 5:08 pm #315312Try to add this code.
.single-product .product-related-wrap .outofstock { display: none; }
-Rui
February 27, 2017 at 5:09 pm #315313Then you would use:
.single-product li.outofstock { display: none; }
February 27, 2017 at 5:15 pm #315318Hi David,
Implemented your code
.single-product li.outofstock {
display: none;
}This is not showing the products as expected, but instead it is adding empty space for those products in list. Please check at link
https://mydhaba.in/shop/food-and-beverages/extra-virgin-olive-oil-ekin/
February 27, 2017 at 6:00 pm #315333This reply has been marked as private.February 27, 2017 at 6:08 pm #315336Hi Rui,
As you can see from attached image. When products are scrolled, it is adding empty space at the end. Earlier it was scrolling only till the products were present.
As suggested I’ve tried after clearing Browser cache and page cache as well.
Thanks
Attachments:
You must be logged in to view attached files.February 27, 2017 at 6:21 pm #315344I see what you mean, in that case a css solution won’t work. It would need a PHP customization that is outside our support scope.
-Rui
March 7, 2017 at 2:16 pm #316197/** * Sorting out of stock WooCommerce products - Order product collections by stock status, in-stock products first. */ class iWC_Orderby_Stock_Status { public function __construct() { // Check if WooCommerce is active if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) { add_filter('posts_clauses', array($this, 'order_by_stock_status'), 2000); } } public function order_by_stock_status($posts_clauses) { global $wpdb; // only change query on WooCommerce loops 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; } } new iWC_Orderby_Stock_Status; /** * END - Order product collections by stock status, instock products first. */
Put this code in the function.php and it will show your out of stock products at the end.
March 7, 2017 at 3:20 pm #316212Thanks @Damsho for providing the code.
-Rui
March 8, 2017 at 8:39 am #316327Would it be possible to integrate this function in atelier theme?
So other people can just set on or off for showing out of stock products at the end of the catalog?March 8, 2017 at 8:58 am #316328@Damsho I will forward the suggestion to the development team so can consider it for a future update.
-Rui
-
Posted in: Atelier
You must be logged in and have valid license to reply to this topic.