Home / Forums / WoodMart support forum / Hide out of stock products or move them at the end
Home › Forums › WoodMart support forum › Hide out of stock products or move them at the end
Hide out of stock products or move them at the end
- This topic has 8 replies, 3 voices, and was last updated 1 year, 9 months ago by
Aizaz Imtiaz Awan.
-
AuthorPosts
-
March 8, 2024 at 1:17 pm #547342
razvanliParticipantHello
I am using the Layouts to create this page and I have some products that are Out of Stock, but I do not want to remove them from the website.
The best option will be to move them at the end of the list.
Or at least to hide them in the elementor layout.How can I do that?
March 8, 2024 at 4:43 pm #547472
Aizaz Imtiaz AwanKeymasterHello,
You need to hide out of stock products from the catalog. Navigate to Woocommerce > Settings > Product > Inventory and you will find this option.
Best Regards
March 8, 2024 at 4:47 pm #547484
razvanliParticipantThis is what I was saying. I dont want to hide them from the entire site.
Is there any other option?March 9, 2024 at 9:41 am #547583
prParticipantWhat I do is change the publication date (I have the category list ordered by last published). Changing the date to previous time thus orders results.
But it is true that it would be interesting to have an automatic option that takes temporarily out-of-stock products to the final part.March 9, 2024 at 1:08 pm #547655
Aizaz Imtiaz AwanKeymasterHello,
You want to move the “out of stock” products at the end of the archive page? If yes, try to add the following code in the function.php of the child theme.
add_filter('posts_clauses', 'order_by_stock_status'); 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() || is_product_taxonomy())) { $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; }Best Regards.
March 9, 2024 at 7:57 pm #547732
razvanliParticipantThanks a lot for this.
You know what will be the perfect scenario for me? To have this products at the end of the list, when showing an archive page and to have the option to have them greyed out.
Any ideas how to achieve that?March 11, 2024 at 10:32 am #547883
Aizaz Imtiaz AwanKeymasterHello,
This code will work on the archive pages.You cannot gray out from the archive pages. If you want to move the “out of stock” products from the end of the shop page you can use this code.
Best Regards.
March 11, 2024 at 10:49 am #547897
razvanliParticipantI can confirm this code worked
March 11, 2024 at 10:54 am #547902
Aizaz Imtiaz AwanKeymasterMost Welcome!!!.
I’m so happy to hear you are pleased with the Theme and Support. XTEMOS strives to deliver the best customer experience, and it makes our day to hear we have accomplished that.
We count ourselves lucky to have you as a customer. You can always reach us at any time. We are always here to help you.
Thanks for contacting us.
Have a great day.Topic Closed.
Best Regards. -
AuthorPosts
The topic ‘Hide out of stock products or move them at the end’ is closed to new replies.
- You must be logged in to create new topics. Login / Register