291 Followers
·
Follow

Image for post
Image for post

Customize the Shipping Method Label in WooCommerce

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”.

Written by

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