2016-09-14 5 views
0

주문이 접수되면 주문 배송 주소에 따라 다른 이메일 주소로 이메일이 전송되도록 WordPress의 functions.php 파일을 수정합니다.워드 프레스 기능을 사용하여 배송지를 비교하십시오.

코드 아래에이 수신자를 변경하기 위해 노력

...

add_filter('woocommerce_email_recipient_new_order', 'wc_change_admin_new_order_email_recipient', 1, 2); 

function wc_change_admin_new_order_email_recipient($recipient, $order) { 
global $woocommerce; 

$recipient = "[email protected]"; 

return $recipient; 
} 

하지만 지금 시도하고 그것이 작동하지 않습니다 배송 국가의 주위에 약간의 논리에 넣어 때 가리키고 전체 사이트로드 및 I하지 않습니다 변경 사항을 롤백하려면 cpanel을 통과해야합니다.

// Change new order email recipient for registered customers 
add_filter('woocommerce_email_recipient_new_order', 'wc_change_admin_new_order_email_recipient', 1, 2); 

function wc_change_admin_new_order_email_recipient($recipient, $order) { 
global $woocommerce; 

if ($order->shipping_country=="AU") 
    $recipient = "[email protected]"; 
} else { 
    $recipient = "[email protected]"; 
} 


return $recipient; 
} 
+0

당신은 특별히 좀 더 자세한 오류 정보를 제공 할 수 있습니다. 디버그 모드를 켜셨기를 바랍니다. 오류를 확인하는 데 도움이됩니다. –

+0

if 문을 사용하여 작성한 코드는 나에 의한 무작위 추측이며, PHP 코드 또는 wordpress를 실제로 알지 못하며 온라인 검색에서 함께 자갈을 긋습니다. 그래서 나는 이것에 대해 알고 그것을 할 수있는 방법을 보여 줄 수있는 누군가를 찾고 있습니다. – user185955

답변

0

코드에 오타가있는 것을 확인했습니다. if 문 다음에 중괄호가 없습니다. 논리가 맞는 것처럼 보입니다. 다음 코드를 사용하여 작동하는지 알려주십시오.

도 좋습니다. turn on WP_DEBUG in your WordPress installation으로 보내주십시오. 그것은 당신이 더 빨리 오류를 잡는 데 도움이 될 것입니다. 공개적으로 웹 사이트를 시작하면 언제든지 사용 중지 할 수 있습니다.

// Change new order email recipient for registered customers 
add_filter('woocommerce_email_recipient_new_order', 'wc_change_admin_new_order_email_recipient', 1, 2); 

function wc_change_admin_new_order_email_recipient($recipient, $order) { 

    global $woocommerce; 

    if ($order->shipping_country=="AU") { 
     $recipient = "[email protected]"; 
    } 

    else { 
     $recipient = "[email protected]"; 
    } 

    return $recipient; 
} 
0
<?php 
// Add everything below to your current theme's functions.php: 
// The email to send can be changed by using a different filter in place of 'woocommerce_email_recipient_new_order' 

add_filter('woocommerce_email_recipient_new_order', 'wc_new_order_cash_on_delivery_recipient', 10, 2); 
function wc_new_order_cash_on_delivery_recipient($recipient, $order) { 

    if ('AU' == $order->shipping_country) { 

     $recipient = "[email protected]"; 
    } 


    return $recipient; 
}