Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WooCommerce - Restore the "(Free)" message when shipping method does not charge any cost.
<?php
/**
* Display (Free) when shipping method does not charge any cost.
*
* @param String $label Shipping method label.
* @param WC_Shipping_Rate $method Shipping method data.
* @return string
*/
function my_wc_custom_free_shipping_label( $label, $method ) {
// Only apply when is free and not using the free shipping method.
if ( '0.00' === $method->cost && 'free_shipping' !== $method->method_id ) {
$label = sprintf( __( '%s: (Free)', 'text-domain' ), $label );
}
return $label;
}
add_filter( 'woocommerce_cart_shipping_method_full_label', 'my_wc_custom_free_shipping_label', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.