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/77043644/hide-shipping-address-in-woocommerce-email-notifications-for-local-pickup-delive
14 lines
625 B
Text
14 lines
625 B
Text
add_filter('woocommerce_order_needs_shipping_address', 'local_pickup_hide_shipping_address', 10, 3 );
|
|
function local_pickup_hide_shipping_address( $needs_address, $hide, $order ) {
|
|
// Define below the shipping method slug that hides shipping address
|
|
$shipping_method_id = 'local_pickup';
|
|
|
|
// Loop through shipping methods for the current order
|
|
foreach ( $order->get_shipping_methods() as $shipping_method ) {
|
|
if( $shipping_method->get_method_id() === $shipping_method_id ) {
|
|
$needs_address = false; // Hide
|
|
break; // Stop the loop
|
|
}
|
|
}
|
|
return $needs_address;
|
|
}
|