I’m making a WooCommerce/Dokan marketplace for people to sell second hand products. As this are second hand products each product should have an inventory of just 1. All products are simple products, no variations.
I want to set by default a stock of 1 to all products. I don’t want the users dealing with setting the stock quantity by themselves.
What I’ve tried
I’ve done a lot of research and haven’t found a solution, I came across this online tutorial:
“Set a Default Stock Quantity for WooCommerce Products” that is what I’m looking for but, the code doesn’t work anymore and produces the infamous white screen of death.
I found some code to add to my child theme functions.php that sets the quantity value to 1 in the product page, it works but it isn’t a complete solution because if someone buys a product the stock won’t be reduced to zero and the product won’t be hidden in the front-end.
What I would like to have
The ideal solution would be code to add to my child theme functions.php that sets stock quantity to 1 by default in all new published products. Of course I’m open to other solutions and plugins but the main goal is that this quantity is set automatically to all new products.
I’m not an experienced developer, I’m self thought, a designer transitioning, that’s why I’m looking for help.
I’m not lazy, I’ve done a lot of research in the past few days and tried many things but haven’t found a solution.
Any help you can provide is appreciated.