Home » WooCommerce: Remove Shipping Labels @ Cart (e.g. “Flat Rate”)

WooCommerce: Remove Shipping Labels @ Cart (e.g. “Flat Rate”)

by Tutor Aspire

WooCommerce functions add the shipping method label on the Cart totals, on the left hand side of the price. This ruins the price amounts alignment (subtotal, shipping, taxes, total) and many clients have asked me to remove it completely. Also, it could be that sometimes you don’t want to show the name of a shipping rate on the front-end. So, here’s how you do it!

WooCommerce: remove the shipping labels on the cart page
WooCommerce: remove the shipping labels on the cart page

PHP Snippet: Remove Non-free Shipping Rate Labels @ WooCommerce Cart & Checkout

For example these:

  • 5 Day Delivery: €25.00
  • Local pickup
  • Free shipping

…will show as:

  • €25.00
  • Local pickup
  • Free shipping

What the snippet does is that it goes looking for a “:” and remove that and whatever is before that. Paid shipping methods are always in the format “LABEL: COST” so this will leave out just the cost. For methods that are free, there is no “:” and therefore the string stays as it is.

/**
 * @snippet       Removes shipping method labels @ WooCommerce Cart / Checkout
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @testedwith    WooCommerce 3.9
 * @donate $9     https://www.tutoraspire.com
 */
 
add_filter( 'woocommerce_cart_shipping_method_full_label', 'tutoraspire_remove_shipping_label', 9999, 2 );
  
function tutoraspire_remove_shipping_label( $label, $method ) {
    $new_label = preg_replace( '/^.+:/', '', $label );
    return $new_label;
}

You may also like