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.
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
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 🙂
22 thoughts on “Putting a limit / minimum on your shipping cost”
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.
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.
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
I’ve written a blog post about how you can add a code snippet to your site. You can find it here:
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?
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.
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?
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: https://aceplugins.com/how-to-add-a-code-snippet/
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?
– 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?
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?
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..
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.
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).
Great post indeed.
but, I would like to have certain methods only visible to some user roles.
how would you achieve this?
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 😉
How to set up a max shipping cost for one specific shipping class?
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.
Is it possible to give different minimum shipping cost for different states or shipping zones ?
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).
Can we have a option for adding a minimum/maximum limit on total shipping cost in the plugin itself for better user experience?
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.
Can you please provide the Snippet for adding additional settings/options through filters/hooks ?