When selling single products that are also available in bulk packages like 4 packs, 6 packs or 12 packs it may raise some inventory issues. Sure it will work well if all those products are separate and they can’t be split up, but when selling bottles of wine for example its common to be able to order a box of 6 bottles and single ones.
A common used technique within WooCommerce for such products is to use variations of a product to sell the multi-quantity packs of those products. However, the inventory issues will remain with that.
It is possible to enable inventory management on a product level, but this doesn’t deduct the proper quantity when selling a box of 6 bottles, since the customer is in fact just purchasing 1 quantity of it.
In this post I’m going to show how you can in fact reduce products with a custom quantity for simple product and variations specifically.
Stock Reduction Setting
Lets start by creating a new setting first. Making it available as a simple product and variation specific setting. The following code snippet adds such setting to the products, I’ve written more about adding product settings before here; Adding Custom Product Fields.
With this in place you’ll have a setting in the ‘Inventory’ section and for variable products also a setting per variation.
Reducing Stock with Custom Quantities
Now for the part that actually reduces the custom stock quantities when someone purchases a product. The following code snippet changes the quantity that is used for reducing stock with a sum that multiplies the quantity purchased with the number that is set in our custom setting.
This takes in account when purchasing a variable product to take the variable setting, or when not set it will take the product global setting instead.
Custom Stock Quantities Reduced
As for the end result, lets take this scenario of having these product variations available;
Each variation has the Stock Reduction settings configured accordingly to 1, 6 and 12 reduction per purchased quantity of the variation. The total inventory quantity is set at the product level.
These variations will be presented accordingly on the product page;
Then when ordering a single item of each of those variations, you’ll see that it reduces the custom stock quantities accordingly from the stock level;
Thats it, hope you’ll find this useful!