Skip to content

Instantly share code, notes, and snippets.

@dhirenpatel22
Created July 19, 2020 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhirenpatel22/c87bd1b569892131db472f3423d14f61 to your computer and use it in GitHub Desktop.
Save dhirenpatel22/c87bd1b569892131db472f3423d14f61 to your computer and use it in GitHub Desktop.
Change label for free standard shipping, when the shipping method’s rate returns $0.00
<?php
/**
* Change label for free standard shipping, when the shipping method’s rate returns $0.00
* @param $full_label
* @param $method
* @return string
*/
function custom_display_zero_shipping_cost($full_label, $method){
if( $method->cost == 0.0 ) {
$full_label = '<span class=”woocommerce-Price-amount amount”>Free Shipping</span>';
}
return $full_label;
}
add_filter( 'woocommerce_cart_shipping_method_full_label', 'custom_display_zero_shipping_cost', 10, 2 );
function add_free_shipping_label_email( $label, $method ) {
if ( $method->cost == 0 ) {
$label = 'Free shipping'; //not quite elegant hard coded string
}
return $label;
}
add_filter( 'woocommerce_order_shipping_to_display', 'add_free_shipping_label_email', 10, 2 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment