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 http://mydomain.com/wp-admin/post.php?post=123&action=edit, 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
  • 9 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.

    Cheers,
    Jeroen

    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:
    https://shopplugins.com/how-to-add-a-code-snippet-to-your-site/

    Cheers,
    Jeroen

    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.

    Cheers,
    Jeroen

    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: https://shopplugins.com/how-to-add-a-code-snippet-to-your-site/

    Cheers,
    Jeroen

    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?

    Thanks,

    Reinout

    Leave a Reply