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/68164986/disable-woocommerce-new-order-email-notification-when-shipping-method-is-not-lo/68167748
15 lines
600 B
Text
15 lines
600 B
Text
function filter_woocommerce_email_recipient_new_order( $recipient, $order = false ) {
|
|
if ( ! $order || ! is_a( $order, 'WC_Order' ) ) return $recipient;
|
|
|
|
// Get shipping method
|
|
$shipping_method = $order->get_shipping_method();
|
|
|
|
// NOT equal (Note: this should be adjusted to the shipping method in your site language)
|
|
// Such as: 'Afhalen' for dutch, etc...
|
|
if ( $shipping_method != 'Local Pickup' ) {
|
|
$recipient = '';
|
|
}
|
|
|
|
return $recipient;
|
|
}
|
|
add_filter( 'woocommerce_email_recipient_new_order', 'filter_woocommerce_email_recipient_new_order', 10, 2 );
|