Skip to content

Instantly share code, notes, and snippets.

@PGeorgiev
Created April 23, 2019 14:03
Show Gist options
  • Save PGeorgiev/c1598784b885be69898b2778aafab901 to your computer and use it in GitHub Desktop.
Save PGeorgiev/c1598784b885be69898b2778aafab901 to your computer and use it in GitHub Desktop.
<?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 serdika_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', 'serdika_free_shipping_label', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment