Reputation: 580
I want to retrieve the title of the shipping method on the cart page. Currently I am using
wc_cart_totals_shipping_method_label( $method );
but that returns the shipping title along with the shipping rate
Flat Rate: $100.00
I just want the "Flat Rate". I have been looking into get_method_title and get_title but not sure if they do what I need to be done.
Upvotes: 1
Views: 1972
Reputation: 253921
To get the label from the WC_Shipping_Rate
object $method
you will have to replace:
wc_cart_totals_shipping_method_label( $method );
by simply:
$label = $method->get_label();
echo $label;
Upvotes: 1