Change wc_cart_totals_shipping_method_label function in Woocommerce Change wc_cart_totals_shipping_method_label function in Woocommerce wordpress wordpress

Change wc_cart_totals_shipping_method_label function in Woocommerce


As you can see in this function you can use woocommerce_cart_shipping_method_full_label filter hook, to manage that change, this way:

add_filter( 'woocommerce_cart_shipping_method_full_label', 'change_cart_shipping_method_full_label', 10, 2 );function change_cart_shipping_method_full_label( $label, $method ) {    $has_cost  = 0 < $method->cost;    $hide_cost = ! $has_cost && in_array( $method->get_method_id(), array( 'free_shipping', 'local_pickup' ), true );    if ( ! $has_cost && ! $hide_cost ) {        $label  = $method->get_label() . ': Free';    }    return $label;}

Code goes in function.php file of your active child theme (or active theme). Tested and works.