What is Shipping?
WooCommerce Shipping is the most efficient way to start printing local and international shipping labels. Get started for free.
What is Free Shipping?
A valid free shipping coupon – Created a coupon that enables free shipping. Minimum Order Amount – Free shipping is available only if the minimum amount is spent. Set this amount in the Minimum Order Amount field that appears if you select this option.
When you want to add additional functionality like display FREE SHIPPING Message based on Minimum amount and country then you can add the below code in the site.
Add below code in your (child) theme’s functions.php
function vivek_patel_wc_free_shipping_notice() {
if ( ! is_cart() && ! is_checkout() ) {
return;
}
if(WC()->customer->get_shipping_country() == "AU")
{
$min_amount = 99; //change this to your free shipping minimum amount
$current = WC()->cart->subtotal;
if ( $current < $min_amount ) {
$remaining = $min_amount - $current;
wc_add_notice( sprintf( '<span class="custom_au_message">Spend an extra %s to get FREE shipping</span>', wc_price( $remaining ) ) );
}
else
{
wc_add_notice("<span class='custom_au_message'>Congratulations! You've now qualified for FREE Standard Shipping.</span>");
}
}
}
add_action( 'wp', 'vivek_patel_wc_free_shipping_notice' );
add_action( 'woocommerce_after_checkout_form', 'vivek_patel_show_notice_shipping' );
function vivek_patel_show_notice_shipping(){
?>
<script>
jQuery(document).ready(function($){
// Set the country code (That will display the message)
var countryCode = 'AU';
$('select#billing_country').change(function(){
selectedCountry = $('select#billing_country').val();
if( selectedCountry == countryCode ){
$('.custom_au_message').parent(".message-container").show();
}
else {
$('.custom_au_message').parent(".message-container").hide();
}
});
});
</script>
<?php
}
AU is a country code. There you can set any country code based on your country. You can easily display FREE SHIPPING Notice in cart and checkout page using the above code.
In this scenario, WooCommerce free shipping is offered when the cart meets with the configured quantity and shipping address in the specified country / city. Example: AU customers can take advantage of free shipping with order total of more than 99 from the store.