당신은 '새 주문' 이메일 알림을 대상으로 woocommerce_email_recipient_{$this->id}
필터 후크에 꺾어 사용자 정의 기능을 사용할 수 있습니다,이 방법 : 곧 WooCommerce 버전 2.7에 대한
add_filter('woocommerce_email_recipient_new_order', 'diff_recipients_email_notifications', 10, 2);
function diff_recipients_email_notifications($recipient, $order) {
// Set HERE your email adresses
$email_zone1 = '[email protected]';
$email_zone_others = '[email protected]';
// Set here your targeted country code for Zone 1
$country_zone1 = 'GE'; // Germany country code here
// User Country (We get the billing country if shipping country is not available)
$user_country = $order->shipping_country;
if(empty($user_shipping_country))
$user_country = $order->billing_country;
// Conditionaly send additional email based on billing customer city
if ($country_zone1 == $user_country)
$recipient = $email_zone1;
else
$recipient = $email_zone_others;
return $recipient;
}
, 몇 가지 새로운 방법 것입니다 WC_Abstract_Order 클래스에서 청구 국가 및 배송 국가와 관련하여 사용할 수 있지만 해당 함수의 실제 코드는 호환 상태를 유지합니다.
$order->get_billing_country(); // instead of $order->billing_country;
$order->get_shipping_country(); // instead of $order->shipping_country;
코드 활성 자식 테마 (또는 테마)의 function.php 파일에 간다 :이 새로운 방법은 각각 get_billing_country()
및 get_shipping_country()
... $ 주문 인스턴스 객체와
사용됩니다 또는 모든 플러그인 파일에도 포함될 수 있습니다.
코드가 테스트되었으며 작동합니다.
관련 답변 : 코드를 잘못 무엇을
그리고 제공이야? –
그건 그냥 예일뿐입니다. – Mario
제공된 예제는 괜찮아 보입니다. 그래서 도움을 요청하는 것은 무엇입니까? 더 많은 코드를 제공하여 문제가 더 명확해질 수 있습니까? – akousmata