ResolvedHow To Filter Products By Stock Status
- This topic has 6 replies, 2 voices, and was last updated 2 years, 8 months ago by
Pablo.
- AuthorPosts
- July 15, 2020 at 9:19 am #24455
Pablo
ParticipantHi Dimitar,
I would like to have a filter for Products that are either “In Stock” or “Out of Stock” without having to use another plugin with unnecessary features.
The Rigid Product Filter is only for the product attributes and the default Woocommerce is only for Price, Rating and Attribute. I know that you set to allow or hide out of stock products site wide under the Woocommerce settings but that is not what I want to do.
I want to allow customers to order items that are out of stock or on backorder but I want to be able to optionally exclude those from the page for customers that only want to see items in stock. Alternatively, I could filter on expected delivery time which I have as a custom taxonomy.
I found an old piece of code from 7 years ago to add a filter https://stackoverflow.com/questions/22973673/woocommerce-admin-filter-by-in-stock-out-of-stock but that crashed my site.
I found a piece of code to exclude products from certain areas https://rudrastyh.com/woocommerce/hide-out-of-stock-products.html but that is not exactly what I need.
Finally I tried this code to sort the products so that “In Stock” is listed first, then “On backorder” then “Out of Stock” but that does not work… https://www.businessbloomer.com/woocommerce-show-in-stock-products-first-shop/
The problem is especially for items that would not be commonly held in stock such as spare parts for products so there would be a lot of items not in stock, only commonly ordered items. I had considered trying different categories such as “Special Order” but that does not help with the issue.
Is there a simple way of achieving either a filter on stock status or ordering products by stock status without breaking the Rigid Theme?
If not, is that something you could consider adding in a future update?
Kind regards,
July 15, 2020 at 9:48 am #24475Althemist
KeymasterHi zuyo,
I am afraid WooComemrce just doesn’t offer such functionality. It can’t be done without modifying the WooCommerce core, so it’s not allowed on official marketplaces like Envato (or the WordPress plugins repository). For such a feature, you’d need to search for filter plugins sold by independent developers, as they don’t have to obey such strict rules like us.
Regards,
DimitarJuly 15, 2020 at 10:50 am #24490Pablo
ParticipantHi Dimitar,
I thought it would be adding a filter in the Theme’s functions.php file calling standard Woocommerce functions – therefore, not modifying core? You have lots of features in the theme that are not part of Woocommerce core, even your own Rigid Product Filters!
On Envato, there are plenty of Product Filter plugins offering In Stock/Out of Stock but I don’t want to install another plugin just for this one piece that I want.
Never mind, I will continue looking for some code.
Kind regards,
July 16, 2020 at 10:59 am #24492Pablo
ParticipantForgot the links to Envato plugins…
https://codecanyon.net/item/woocommerce-product-filter/26135072
https://codecanyon.net/item/woof-woocommerce-products-filter/11498469July 16, 2020 at 10:59 am #24491Pablo
ParticipantForgot the links to Envato plugins…
https://codecanyon.net/item/woof-woocommerce-products-filter/11498469
https://codecanyon.net/item/woocommerce-product-filter/26135072July 16, 2020 at 12:00 pm #24538Althemist
KeymasterYes, you’re right but adding our custom features doesn’t require modifying core WooCommerce features. I’ll discuss with the team if it’s possible to add such functionality, but can’t guarantee as it should be in the theme plugin, while this functionality is in the theme.
July 16, 2020 at 12:19 pm #24543Pablo
ParticipantI found that the code (I posted above from business bloomer) to order the products by “In Stock” first does work, it must have been a page caching issue. But that is not ideal if you want to order by another parameter, it would be nicer to have the option to filter on the stock status. I don’t know about the programming detail but I would have thought that you are only querying back the items that have a certain stock status. So that is no different to any other filters except you are checking stock status (through standard function calls) rather than the attribute “brand”, “colour” or whatever?
Maybe it is more difficult to implement than it seems to me though. I appreciate the fact that you will discuss it.
- AuthorPosts
You must be logged in and have valid license to reply to this topic.