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/77360830/hide-woocommerce-displayed-shipping-cost-when-local-pickup-is-selected
11 lines
565 B
Text
11 lines
565 B
Text
add_filter( 'woocommerce_cart_shipping_method_full_label', 'custom_cart_shipping_method_full_label', 10, 2 );
|
|
function custom_cart_shipping_method_full_label($label, $method){
|
|
$chosen_methods = WC()->session->get('chosen_shipping_methods');
|
|
$chosen_method = explode(':', reset($chosen_methods) );
|
|
$chosen_method = reset($chosen_method); // Get the chosen shipping method
|
|
|
|
if ( $method->get_method_id() !== 'local_pickup' && $chosen_method === 'local_pickup' && $method->cost > 0 ) {
|
|
$label = $method->get_label();
|
|
}
|
|
return $label;
|
|
}
|