This code enables the store owner to set a out of stock ( OOS ) threshold per simple and variable product.
Example : If the stock quantity is 30 and you set the Out of stock threshold to 10, the stock level will display as 20 in stock as seen in the demo video.
You set the OOS threshold on the Product Data – Variable Product > Variations tab as seen in this screenshot.
The demo video shows when the Out of Stock threshold is set above the Stock Quantity, the product will display Out of stock and the Add To Cart button is disabled on variations and removed on single products. If the OOS threshold is below the Stock Quantity, the Simple Product or variation is In stock and the stock limit displays making it available for purchase as the Add To Cart button re-enabled.
There’s only 1 step : Install as a new plugin or copy & paste the PHP code ( without the opening PHP tag ) to the end of your child themes functions file or custom functionality plugin. You can then set the threshold for simple products on any Edit product screen using the Inventory tab.
For Variable products, set the OOS threshold on the Product Data > Variations tab for each variations as seen in the demo video.
Make sure the Stock management > Track stock quantity for this product is unchecked as the settings for each threshold are available on the Variations tab.
Note : The download file also contains PHP code which enables you to show stock levels offset by the threshold.