1. Home
  2. WC Vendors Pro
  3. Remove Shipping Method Title
  1. Home
  2. Code Snippets
  3. Remove Shipping Method Title

Remove Shipping Method Title

The following code will remove the Shipping method title from the cart, checkout and emails. This is a modified version of the wc_cart_totals_shipping_method_label function from WooCommerce.

add_filter( 'woocommerce_cart_shipping_method_full_label', 'remove_shipping_method_title', 10, 2 ); 
function remove_shipping_method_title( $label, $method ){ 

	$new_label = ''; 

	if ( $method->cost > 0 ) {
		if ( WC()->cart->tax_display_cart == 'excl' ) {
			$new_label .= wc_price( $method->cost );
			if ( $method->get_shipping_tax() > 0 && WC()->cart->prices_include_tax ) {
				$new_label .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
			}
		} else {
			$new_label .= wc_price( $method->cost + $method->get_shipping_tax() );
			if ( $method->get_shipping_tax() > 0 && ! WC()->cart->prices_include_tax ) {
				$new_label .= ' <small class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>';
			}
		}
	}

	return $new_label; 
} // remove_shipping_method_title()

This code changes the display from

To remove the shipping title like this:

 

filters

Updated on May 17, 2017

Was this article helpful?