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?
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.
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');
}
}