Restrict Products to Checkout by Any Multiple

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 :

  1. Set products for sale by multiple of any quantity
  2. 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.

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.