Recently whilst working on one of my own projects, I had a rule setup which gave FREE Shipping to anyone purchasing 3 items or more in the UK.

I wanted to show a message on the “Basket” page showing how many more items someone needed to add to their basket to qualify for Free Shipping. I was able to achieve this by adding the below code to my functions.php file.

//Show Quantity needed to qualify for free shipping UK only
add_action( 'woocommerce_before_cart', 'ds_free_shipping_cart_notice' );
function ds_free_shipping_cart_notice() {
    $threshold = 3;
    $current = WC()->cart->get_cart_contents_count();
	$billing_country = WC()->customer->get_billing_country();
    if ( $current < $threshold && WC()->customer->get_billing_country() == 'GB' ) {
        wc_print_notice( 'Order ' . ( $threshold - $current ) . ' more and shipping is on us', 'notice' );


The end result was as below where currently only one item is in the basket and the user is being shown that two more need to be added to get Free Shipping.

This message is also only shown to those who are in the UK based on their billing country which gets set by default using Geolocation.

Feel free to use the above and amend it as needed, here’s a guide on how to amend it to suit your needs:

  • To change the number of items needed to qualify just change the number in $threshold
  • To change the country where this message is restricted to change the country code in this line of code if ( $current < $threshold && WC()->customer->get_billing_country() == ‘GB’ ) – list of country codes
  • To set the customer location to their Geolocation make sure in your Woocommerce tab, under General you select the “Default Customer Location” to “Geolocate”
  • To change the message you want to show change it in the wc_print_notice line above, ensure that you keep the speech marks as well as not removing the code around it as this will break otherwise
Was this article helpful?