The code in this mini plugin enables you to set custom out of stock threshold for simple products in WooCommerce. The plugin :
- Adds a custom field to add custom out of stock text.
- Add a checkbox to enable out of stock text ( custom or default ) or remove out of stock text.
- Adds an Out of Stock Threshold field on the Inventory tab for simple products.
- Removes the add to cart button when your custom out of stock threshold equates inventory levels to out of stock.
- Optionally displays out of stock text. ( disabled by default ).
Example 1 : The 1st shows an inventory level of 49 and an Out of stock threshold of 50 so the product becomes out of stock and the add to cart button is removed.
Example 2 : The 2nd shows an inventory level of 50 and an out of stock threshold of 49 so the product displays in stock 1.
If the checkbox is checked, the out of stock text displays the default out of stock text unless custom out of stock text is added to the custom field. If the checkbox is unchecked, no default or custom out of stock text is displayed.
Installation
Install as a new plugin or copy and paste the PHP code from the plugin.php file to the end of your child themes functions file or custom functionality/code snippets plugin.
You must be logged in to post a comment.