mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://stackoverflow.com/questions/77959320/customize-shipping-label-from-woocommerce-cart-and-checkout-pages
10 lines
413 B
Text
10 lines
413 B
Text
add_filter( 'woocommerce_cart_shipping_method_full_label', 'display_only_shipping_method_price', 10, 2 );
|
|
function display_only_shipping_method_price( $label, $method ) {
|
|
// HERE define your targeted rate id
|
|
$targeted_rate_id = 'flat_rate:4';
|
|
|
|
if ( $method->id === $targeted_rate_id && 0 < $method->cost ) {
|
|
$label = str_replace( $method->label . ': ', '', $label);
|
|
}
|
|
return $label;
|
|
}
|