I have a specific function I would like to implement with WooCommerce if possible. Is there a way that I can have WooCommerce check if the quantity of items in the cart is divisible by 12?
Basically I have a shop setup but I need customers to order in quantities of 12 (that’s the size of the boxes I ship the items in). However, I have a few product variations (size, width, etc.) and I want the customers to be able to mix and match variations in order to reach a quantity of 12 (or 24, 36, etc.)
I’m gathering that the easiest way to do this is probably to install a function that checks the total cart quantity and if it is divisible by 12. If so, they can proceed. If not, they need to change their quantity to continue. Does anyone have experience on if there is a plugin that suits this need or if there is some custom code I can add?
Any help is greatly appreciated.
Regards,
Ryan
This should work for you:
Add the following to the
functions.php
file, at checkout it will check and see if the quantity is a multiple of 12, if it is then it’s fine, if not you get the error messageYou need to buy in quantities of 12 products
and won’t be able to proceed.The above is slightly modified from this post.