Skip Navigation

[Resolved] Out of stock products still showing in View results

This support ticket is created 4 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by Joe H. 4 years, 1 month ago.

Assisted by: Shane.

Author
Posts
#1833797

Tell us what you are trying to do?
In my woocommerce Inventory settings I have it set to 'Hide out of stock items from the catalog' . This works on the default woocommerce Shop page but not in my Toolset View on my homepage or elsewhere.

I want to:

1. Force the default (and maximum) inventory for all Products added to the store to be 1. Each product is one of a kind.
2. Only allow a Product to be purchased once. 1 purchase should set inventory to 0.
3. Do not display any products on the front end that are out of stock/0 inventory. Once the Product is purchased it is gone - no longer in search results, no longer in View loops, gone from front end entirely.

I am surprised to discover that Toolset has an entire course on building a woocommerce store but says nothing at all about the fact that a View displaying products completely ignores inventory. Unless i am mistaken?

What is the link to your site?
hidden link

#1834503

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Joe,

Thank you for getting in touch.

1. Force the default (and maximum) inventory for all Products added to the store to be 1. Each product is one of a kind.

This is something that will need to be set when you are creating the product or by using a 3rd party plugin to set the quantities for the products globally.

2. Only allow a Product to be purchased once. 1 purchase should set inventory to 0.
This is something that is done by woocommerce by default so it will automatically set the item to out of stock.

3. Do not display any products on the front end that are out of stock/0 inventory. Once the Product is purchased it is gone - no longer in search results, no longer in View loops, gone from front end entirely.

In order to guide you on this I will need to know if you are using the Blocks setup or the classic views setup because you can filter out for only the products that are in stock.

Thanks,
Shane

#1835033

My issue is resolved now. Thank you!

My Products are being created by front end TS forms, so I needed a programmatic way to set the stock level. Google turned up this snippet that solves it for me:

add_action('save_post_product', 'myWoo_savePost', 10, 3);
function myWoo_savePost($postID, $post, $update) {
    if (!$update) {
        //  $update is false if we're creating a new post
        update_post_meta($post->ID, '_manage_stock', 'yes');
        update_post_meta($post->ID, '_stock', '1');
    }
}