Force Quantity Multiple for Variations in WooCommerce

This solution enables you to force customers to purchase specific product variations by any multiple you set in the code. In this example, product variation id 15463 for size large attribute for t shirts can only proceed to checkout if purchased by quantities of 5.

If the quantity matches the multiple set in your code, the customer can proceed to checkout, otherwise, they get this error message on the checkout page :

Demo Video

Installation

Copy and paste the PHP code to the end of your child themes functions.php file or custom code/snippets plugin.

Code Settings

Swap out your variation id on lines 12 and 30.

Get Variation Id

The id for each variation is shown next to the variation on the Edit Product > Product Data – Variable Product > Variations.

Download Folder

Was This Tutorial Helpful?

Free

$0

Access only to all free tutorials per month.



Monthly

$75

Access to 10 premium tutorials per month.


Tutorial Request


Includes code guarantee and coding support.

Yearly

$500

Access to 15 premium tutorials per month.


Monthly Tutorial Request


Includes code guarantee and priority coding support.