Customize the Shipping Method Label in WooCommerce

Avishai
Avishai
Oct 9, 2017 · 1 min read

WooCommerce is a great tool to get an e-commerce shop up and running quickly, but sometimes the developers don’t think their ideas all the way through.

A recent example of this when using their shipping formulas, whereby you can calculate a custom shipping rate based on variables like [qty].

If you wanted to offer free shipping on 3+ items, the shipping method would calculate the total cost as $0.00. But, when WooCommerce sees $0.00, the shipping method label returns the name only, not the amount. This can lead to confusion for the customer, since it’s not clear that the shipping cost is now free.

To fix that, add this to your functions.php:

/****** 
** Change label for free standard shipping, when the shipping method’s rate returns $0.00
******/
add_filter( ‘woocommerce_cart_shipping_method_full_label’, ‘custom_display_zero_shipping_cost’, 10, 2 );
function custom_display_zero_shipping_cost($full_label, $method){
if( $method->cost == 0.0 ) {
$full_label = $full_label . ‘: <span class=”woocommerce-Price-amount amount”>Free!</span>’;
}
return $full_label;
}

Now, your shipping method label will say something like “Standard Shipping: Free!” instead of just “Standard Shipping”.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store