In my experience around shipping in WooCommerce I’ve found that there are countless different needs for setting up shipping cost. One that comes back from time to time is setting up a minimum or maximum shipping cost to shipping rates. In this post I’ll show you ways on how you can setup these caps on your shipping cost.

Setting up a maximum shipping cost

Depending on your needs you may want to setup a maximum shipping cost for all shipping rates. In the code snippet below it will put the maximum shipping amount you entered on all the shipping rates and automatically adjust the shipping rates.

Apply maximum shipping cost to certain shipping rates

Of course setting up a maximum shipping cost for all shipping rates may not go well if you have some sort of for example a setup with both standard and expedited shipping. This code snippet will allow you to only setup the maximum to certain shipping rates based on their shipping rate ID.

Setting up a minimum shipping cost

If you want to setup a minimum shipping cost, the example below will setup a minimum shipping cost of $10 for each shipping rate.

Setup minimum shipping cost to certain shipping rates

Just like the maximum shipping cost example, setting up a minimum cost for each rate may not be what you need. In the example below you can setup the minimum shipping cost per shipping rate. You can enter multiple shipping rates in the comma separated list if want to.

Closing words

If you’re using my Advanced Shipping plugin and want to setup the min/max shipping cost based on the shipping rate IDs, you can find the IDs of the shipping rate in the URL when editing a shipping rate. For example, if the URL is, then 123 would be the shipping rate ID.

Please leave a comment below if this was helpful for you, or if you ran into any challenges 🙂

Jeroen Sormani

I'm a professional WordPress plugin developer on a mission to create the best plugins for my clients. I'm specialised in developing general WordPress, WooCommerce and Easy Digital Downloads plugins.

Interested in talking about a WordPress project? Get in touch!

Follow me on Twitter

26 thoughts on “Putting a limit / minimum on your shipping cost

Rey October 18, 2016 at 4:03 pm

Hi Jeroen,

Thanks for this, i been searching for this kind of function, But how can this be applied for a multiple shipping method with its own minimum purchase.? For example flat rate for $10 and store pickup for $15.

Jeroen October 18, 2016 at 7:31 pm

Hi Rey,

You’d need to customize the code a bit, but this is definitely possible. I think the easiest way would be to grab the second code snippet and add those multiple times for your different rates. Do remember to change the function name for each, otherwise those will clash.


julian cooke November 15, 2016 at 4:49 pm

Setting up a maximum shipping cost

Where do i find the PHP file for this, so i can add your code, is it in the Functions.php in the backend of wordpress on the ftp

Jeroen February 6, 2017 at 8:56 am

Hi Julian,

I’ve written a blog post about how you can add a code snippet to your site. You can find it here:


Richard February 6, 2017 at 5:33 am

Hi Jeroen
I’ve been looking around for a simple way to add a maximum shipping cost for an order. I’d be interested if you have a plugin or extension that can add this feature without me having to add php code in myself to WordPress. Do you offer a version of your Advanced Shipping plugin with this feature already included?

Jeroen February 6, 2017 at 8:58 am

Hi Richard,

The Advanced Shipping plugin doesn’t have this feature available, though it is possible to add a input field with the option through a custom code snippet (not sure if thats better in your case, as there would be a UI for it).

Depending on your needs, you may also be able to setup the shipping rates in a way so they never exceed the amount, but can’t say that without more details.


Richard February 6, 2017 at 9:41 am

Thanks for your reply. Here’s my situation, I run a store that has a variety of different products e.g., stickers, t-shirts, cups. Each of these will have a different shipping cost or class e.g. t-shirt $5 shipping, sticker $1 shipping, cup $3 shipping. I’d like to set it so that when all shipping is added up it never goes over $7.70. I have Admin access to the wordpress plugins using wordpress admin dashboard but cannot access the function php via FTP. Preferably I’d like to install a plugin do install these options. Based on this what would be the best option for me from your experience?

Jeroen February 6, 2017 at 9:55 pm

Hi Richard,

There should also be a option to edit the functions.php file from within the WP Dashboard under the ‘Appearance’ menu.
I do recommend that you test it very good on a local system first, because if something goes wrong through that editor and it causes an error on the site, you won’t be able to undo it without FTP access.

Otherwise you could also insert the code into a macro-plugin and use it like that.

I wrote more about adding code snippets here:


Rynout February 20, 2017 at 9:02 pm

Hi Jeroen,

I don’t understand code… but I guess if I paste in your snippet to apply a max. shipping cost to a certain shipping rate, enter the rate and the appropriate shipping ID’s and I’m good to go?

2 questions:

– If I have different limits for different shipping ID’s I just add the same code more than once?
– Dumb question perhaps but where can I find the ID’s of my shipping rates?



Franco May 1, 2017 at 12:15 pm

nice post, very useful. For me the generic minimum fee works fine, but not when I have to filter for a shipping rate ID. I looked on the woocommerce_shipping_zone_methods table where I can see the instance_id and method_id (which is a name, not an integer), but somehow the code does not find them. Using WC 3.
What am I doing wrong?

Franco May 1, 2017 at 12:28 pm

Tried with ‘flat_rate:4’ and similar and it worked 🙂
Just one issue: if I apply the VAT the numbers are wrong, it seems to add a fix amount per item (0.16 in my case) which has nothing to do with the VAT or any other value..

Carl June 30, 2017 at 10:20 am

Thanks Jeroen, that is really useful.
Is there a way to set maximum tax for the delivery.
Currently, the delivery tax is worked out per item so although the delivery cost maxes out the delivery tax does not.
Thanks, Carl

Jeroen March 6, 2018 at 9:44 am

Hi Carl,

Best way would probably to also initiate a tax re-calculation. I’ve updated the code snippets to add this, but note that this is calculated for the entire order, not on the ‘per_item’ as can be set when actually adding a shipping rate (as that argument is not known at the time of the filter).


Rodger March 1, 2018 at 10:54 pm

Great post indeed.
but, I would like to have certain methods only visible to some user roles.
how would you achieve this?

Jeroen March 6, 2018 at 9:23 am

Hi Rodger,

Having certain shipping method for user roles is out of scope for this blog post.
If you’re looking for a plugin that would allow you to setup something like that I can of course recommend my Advanced Shipping plugin 😉


franck March 30, 2018 at 4:17 pm

Hi Jeroen,
How to set up a max shipping cost for one specific shipping class?

Jeroen Sormani March 30, 2018 at 6:36 pm

Hi Franck,

This isn’t possible with this code snippet, but you can take a look at the Advanced Shipping in combination with the WAS Advanced Pricing extension, those plugins will allow you to setup shipping cost per class, with min/max conditions so you can possibly limit it to your needs.


Pack My Food August 10, 2021 at 12:31 pm

Is it possible to give different minimum shipping cost for different states or shipping zones ?

Jeroen Sormani August 10, 2021 at 2:50 pm


Sure, I’d recommend to use the snippet within the ‘Setup minimum shipping cost to certain shipping rates’ section. With that you can setup different rates per zone and each rate within zones will have its own shipping rate ID that can be used to setup the different minimum costs per state (zone).


Reshma April 27, 2022 at 4:20 pm

Can we have a option for adding a minimum/maximum limit on total shipping cost in the plugin itself for better user experience?

Jeroen Sormani April 27, 2022 at 9:28 pm


This is currently not planned as a feature in any of my plugins. If really desired the plugin does support adding additional settings/options through filters/hooks that would allow to add this.


Reshma May 2, 2022 at 9:43 am

Can you please provide the Snippet for adding additional settings/options through filters/hooks ?

Many Thanks

Robyn Walters June 15, 2023 at 2:50 am

Hi Jeroen.

Many thanks for your work.

We’re using the above snippet very happily with a $20 max on shipping. We just noticed that it does not add any tax to shipping when that maximum is applied. It should be 10%.

Everything else is working as it should. Any clues to what could be wrong? Is there some value in the “recalculate shipping tax” section that should be tweaked?

Thanks again.

Jeroen Sormani June 15, 2023 at 10:30 am

Hi Robyn,

Just tested the snippet and still appears to work for me. Are your shipping taxes configured correctly?


Robyn Walters June 17, 2023 at 2:27 am

Thanks so much for checking, Jeroen! Much appreciated.

I did assume our shipping taxes are configured correctly as they work as they should on all transactions unless the maximum shipping is applied. It’s only then that suddenly there is 0 tax on the shipping component. Strange.

I’ll certainly re-check our configuration again now tho. Any clues what to look for? Sorry to be a pain. I don’t want to mess with anything that’s working for the majority of transactions.

Klaudia February 7, 2024 at 4:10 pm

For the question: “Is it possible to apply different minimum shipping charges for different countries or shipping zones?” Your answer: “Of course, I recommend that you use the snippet in the “Configure minimum shipping charges for certain shipping rates” section. This way, you can define different rates per zone and each rate within zones will have its own shipping rate ID that can be used to define the different minimum charges per state (zone).”

I’m trying to add another minimum charge for another zone but the code doesn’t work. Can you write me a code example. My zone to add is 4 and the minimum is $50. Thank you for your understanding.

Leave a Reply