The PHP code in this downloadable folder enables you to prevent your customers from proceeding to checkout in WooCommerce unless they purchase specific products by any multiple you set in the code.
In this example, we set one product with a product id of 111537 so it can only be bought in batches of 5. The buyer can still add the product to cart, but a error notice displays if the quantity doesn’t match a multiple of 5.
In summary, the code enables you to :
- Set products for sale by multiple of any quantity
- Restrict checkout if the quantity does not match your multiple
Video Demo
Code Installation
Copy and paste the PHP code to the end of your child themes functions file or custom code snippets/functionality plugin.
Settings
- Line 11, add your multiple
- Line 12, add a product id or comma separated list of products ids.
- Line 30, add your message to be displayed in a error notice when the quantity does not match your multiple.
Was This Tutorial Helpful?