mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-03 12:12:25 +08:00
https://stackoverflow.com/questions/64878670/replace-zero-cost-to-free-from-woocommerce-shipping-method-full-label
8 lines
420 B
Text
8 lines
420 B
Text
add_filter( 'woocommerce_cart_shipping_method_full_label', 'Add_free_to_shipping_label_for_zero_cost', 10, 2 );
|
|
function Add_free_to_shipping_label_for_zero_cost( $label, $method ) {
|
|
// If shipping method cost is 0 or null, display 'Free' (except for free shipping method)
|
|
if ( ! ( $method->cost > 0 ) && $method->method_id !== 'free_shipping' ) {
|
|
$label .= ': ' . __('Free');
|
|
}
|
|
return $label;
|
|
}
|