Show "Free" Next to Zero-Cost Shipping Methods
Adds a clear "Free" label to shipping options that cost nothing, such as local pickup, which WooCommerce otherwise shows with no price at all.
Opens WPIDE on
Code
$wpide_free_text = 'Free'; // Label added to zero-cost methods.
add_filter( 'woocommerce_cart_shipping_method_full_label', function ( $label, $method ) use ( $wpide_free_text ) {
if ( (float) $method->get_cost() > 0 || false !== strpos( $label, $wpide_free_text ) ) {
return $label;
}
return $label . ': <strong>' . esc_html( $wpide_free_text ) . '</strong>';
}, 10, 2 );
Notes
Change $wpide_free_text to translate or restyle the label.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.