Minimum Quantity Based on Shipping Method in WooCommerce

The PHP code in this download folder displays a error notice and prevents checkout when the quantity is below a set minimum based on the shipping method selected on the cart page.

In this example, we set a minimum quantity of 20 when any local pickup point method is selected and a minimum of 10 when the delivery method is checked.

When you click the above gallery images, you’ll find the error notice added based on the chosen shipping method changes the minimum quantity from 10 to 20.

Note : You can use this code with multiple shipping methods, multiple minimum quantities and any shipping plugin.

Installation

There’s 2 simple steps :

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

2. Swap out the shipping method id’s on lines 32, 35 and 38 and also swap out the minimum quantities on lines 33, 36, 39 and 42.

Find Shipping Method ID’s

You can inspect each shipping method to find the id for each.

Find Shipping Method ID's

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.