Everybody wants to increase the average order value for their store, right? A good way to do this is to offer free shipping above a certain order amount. If you have this on your site you should of course promote this as a selling point on a prominent and default position.

Alongside with that, it would be good to help the customer remind in the cart if they’re close to the free shipping amount with a notification saying something like “Add $10 more to your basket to receive free shipping!”.

In this post I’ll provide a code snippet that you can use to display such message on the cart/checkout page when using the WooCommerce Core ‘Free shipping’ option. I’ll also provide a solution when using the Advanced Shipping or Advanced Free Shipping plugins.

Showing a free shipping notice for WooCommerce Core free shipping rates

Using the following snippet you can show the notice on the cart / checkout page. It will only appear when the minimum order amount setting is set.

You can remove some of the lines if you only want to display it at the cart / checkout page as described inline.

Showing a free shipping notice for Advanced Shipping

If you setup a free shipping option with the Advanced Shipping / Advanced Free Shipping plugin then the above code snippet won’t work as that only recognises the ‘Free shipping’ rate of WC Core and the respective settings. Because of the conditions it is very difficult to setup a code snippet that would fit the exact requirements.

Therefore the easiest solution would be to use the Advanced Messages plugin. Just like the other ones, this plugin has similar conditions and will allow you to setup conditional messages throughout your store.

Here’s how an example setup would look like;

1. The free shipping rate

2. The message

The message would have a similar setup. I’ve added a additional condition to ensure it doesn’t show when there’s too big of a gap between the free shipping amount and the cart subtotal.

3. The message at the cart

  • 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
  • 8 thoughts on “Showing a ‘Add $10 more for free shipping’ notice

    Andy September 26, 2017 at 7:36 pm

    Hi Jeroen

    Looks like a useful post, but it isn’t clear where we need to paste the code snippet to make it work.

    Thanks!

    Jeroen September 26, 2017 at 7:48 pm

    Hi Andy,

    You can copy&paste the contents of the script to your (child) themes functions.php. I usually recommend doing it over FTP.
    If wanted you can read more about code snippets here: https://shopplugins.com/how-to-add-a-code-snippet-to-your-site/

    Cheers,
    Jeroen

    Nick November 19, 2017 at 4:14 am

    The snippit is cool, but it takes into account shipping costs.

    For example

    $50 item
    $20 shipping

    Free shipping => 100

    Spend another $30 to get free shipping. Notice should say spend another $50. Needs to be item total not cart total.

    Jeroen November 19, 2017 at 9:25 am

    Thanks for noticing Nick!

    I’ve just modified the script to get that sorted out.

    Cheers,
    Jeroen

    Matteo November 21, 2017 at 11:39 am

    Hello Jeroen,

    thank you very much for this very handy piece of code!

    I don’t want to steal your time, because it’s always uncomfortable to ask somebody already nice to further being helpful!

    Yet, I have a question about a situation where I have two different free shipping options, regular free shipping, and priority one.

    As I turn on your code, I get a duplicate message, one per free shipping method.
    These are the messages:
    Add 10$ more to get free shipping!
    Add 70$ more to get free shipping!

    It would be great to be able to customize the output like this:
    Add 10$ more to get free tracking shipping!
    Add 70$ more to get free priority shipping!

    Do you think this is going to be crazy? =/

    Kind regards,

    Matteo

    Jeroen November 22, 2017 at 10:47 am

    Hi Matteo,

    Shouldn’t be too difficult, you can either create a second code snippet based on the initial one. Or possibly a easier solution would be to display the shipping title in the notice like so:
    Line #26: wc_add_notice( sprintf( 'Add %s more to get %s!', wc_price( $remaining ), $method->get_title() ) );
    (untested)

    This should show the shipping title in the notice, making it more dynamic and in-line with what you’re looking for.

    Regards,
    Jeroen

    Matteo November 24, 2017 at 4:17 am

    Thanks Jeroen, I’ll take a look and try and see how far I can go =)
    And thank you again for sharing!

    Matteo

    Matteo November 26, 2017 at 5:44 am

    I think I grasped how it works! Thanks! =)
    Now I’m out to find a way to separate the variable from the text, so not to directly copy-paste the title of the shipping method! Sure thing, coding is fun!

    Matteo

    Leave a Reply