1

I use a custom shipping plugin for my WooCommerce called Table Rate. When the cart's total is more than X $, the shipping cost is set to 0.

In the cart page, when there is a shipping cost, it currently displays, for example "Postal delivery: $6,00" in the shipping method section. When the shipping is free, it displays "Postal delivery".

I would like that when the shipping is 0, it adds the text "(Free)" after "Postal delivery" in the cart and checkout page, but I can't find out where this is managed in WooCommerce. I have checked the different template files, but get stuck there. I guess it could be done with a hook in the functions.php file but I'm quite inexperienced with this.

Thank you very much.

Shipping cost at 0

0

you may try this

function custom_label( $label, $method ) {
    if ( $method->cost == 0 ) {
        $label .= "(Free)";
    }

    return $label;
}
add_filter( 'woocommerce_cart_shipping_method_full_label', 'custom_label', 10, 2 );
  • That's exactly what I needed. From that, I can now include method selection and other things. Thank you very much! – Lesk Oct 3 '17 at 13:48
  • you're welcome, don't hesitate to upvote the anwser ;) – Temani Afif Oct 3 '17 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.