2014-05-08 6 views
0

며칠 동안 내 머리카락을 꺼내 ​​왔습니다. 시나리오는 1 개의 상점에 2 개의 위치가 있으므로 체크 아웃시 선택된 운송 국가를 기반으로 새로운 주문 알림이 관련 이메일 주소로 가야합니다.배송 국가를 기반으로하는 새로운 전자 메일로의 Woocommerce 새로운 주문 알림

부분적으로 작동하도록했습니다.

는 테스트 단계 동안 나는 완료 순서를 얻기 위해서 "직접 은행 송금"지불 방법을 사용했다. 아래의 코드는 그 지불 방법과 잘 작동하지만 나중에 주문이 페이팔을 통해 이루어지면 더 이상 작동하지 않는다는 것을 발견했습니다. 가상으로 제품을 변경하는 경우

는 Futhermore는 다음 페이팔과 함께 작동하지만 곧 당신은

add_filter('woocommerce_cart_needs_shipping', '__return_true'); 

후 다시 작동이 중지 운송 옵션을 다시 가져 추가한다.

여기에 지금까지 내 코드입니다

global $woocommerce; 
if (strtolower($woocommerce->customer->get_shipping_country()) === 'us') { 
$this->send('[email protected]', $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); 
} else { 
$this->send('[email protected]', $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); 
}; 

희망 누군가가 내가 놓친 게 분명 뭔가, 사전에 감사를 발견 할 수 있습니다!

업데이트 : Zapier는 작동하지만 몇 가지 제한 사항이 있지만 타사 앱이 필요없는 해결책을 찾고 싶습니다.

답변

0

Zapier라는 사이트를 사용하여이 작업을 수행 할 수있는 또 다른 방법이있다. WooCommerce 중 하나 인 여러 API를 연결할 수 있습니다. 배송 국가가 미국 인 경우 [email protected]으로 전자 메일을 보내고 그렇지 않은 경우 [email protected]으로 전자 메일을 보내는 방아쇠를 만들면됩니다.

+0

감사합니다 zapier는 내가해야 할 일을 달성했습니다! –

+0

제안을 주셔서 감사합니다. 문제가 해결되었다고 생각했지만 자비는 실제 이메일 내용에 충분히 융통성이 없어 내 요구 사항이 중요했습니다. –

1

해결책을 찾았습니다. 클래스-WC-이메일 새로운 order.php의 미래에 같은 문제를 가진 사람에 대한

, 대체

$this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); 

if ($this->object->shipping_country === 'US') { 
$this->send('[email protected]', $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); 
} else { 
$this->send('[email protected]', $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); 
} 

문제가 글로벌은 $ woocommerce을 사용했다와 주문 자체에서 가치를 얻어야 할 때 고객으로부터 가치를 얻으십시오.

다른 체크 아웃 필드를 기준으로 조건을 만들려면 당신이

그냥 대체 클래스 WC-API-orders.php의 목록을 찾을 수 있습니다

$order->shipping_country 

$this->object->shipping_country 
0

이것은 내가 본 다른 옵션보다 효과적입니다. 감사합니다! billing_state에 대해 shipping_country을 변경했습니다.

두 개 이상의 변형을 추가 할 수 있습니까?이 개 값으로 선택 - 나는 사용자 정의 체크 아웃 필드를 기준으로 조건 전자 우편을 허용하는 코드를 적용하려고

if ($this->object->billing_state === 'SC') { 
    $this->send( 
     '[email protected]', 
     $this->get_subject(),  
     $this->get_content(), 
     $this->get_headers(), 
     $this->get_attachments() 
    ); 
} 

    if ($this->object->billing_state === 'RS') { 
     $this->send( 
      '[email protected]', 
      $this->get_subject(), 
      $this->get_content(), 
      $this->get_headers(), 
      $this->get_attachments() 
     ); 
    } 

if ($this->object->billing_state === 'PR') { 
     $this->send( 
      '[email protected]', 
      $this->get_subject(), 
      $this->get_content(), 
      $this->get_headers(), 
      $this->get_attachments() 
     ); 
    } 


    else { 
     $this->send( 
      '[email protected]', 
      $this->get_subject(), 
      $this->get_content(), 
      $this->get_headers(), 
      $this->get_attachments() 
     ); 
    } 
+1

나는 닫는 브래킷이 실종 된 것 같아! – Meloman

+0

누락 된 브래킷을 찾지 못했습니다 (저는 초보자입니다). '경우 ($ this-> 개체 -> billing_state === 'SC') { $ this-> 전송 ('[email protected] : "그 밖에"전자 메일은 내 코드가 작동하지 않습니다 ', $ this-> get_subject(), $ this-> get_content(), $ this-> get_headers(), $ this-> get_attachments()); ($ this-> object-> billing_state === 'RS') { $ this-> send ('[email protected]'(), $ this-> get_headers(), $ this-> get_attachments()); } else { $ this-> send ('[email protected]', $ this-> get_subject(), $ this-> get_content(), $ this-> get_headers(), $ this-> get_attachments()); }' –

+0

코드의 들여 쓰기를 다시합니다. 보시다시피 마지막 "}"이 (가) 없습니다. 하지만 실제로는 두 번째 전에 생각합니다() {...} 게시하고 답변 드리겠습니다. – Meloman

0

: 뭔가 같은 말을하자. 설명 된대로 이메일이 발송되지 않았습니다.

if ($this->object->billing_divisions === 'sprinkler') { 
    $this->send('[email protected]', $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); 
} else { 
    $this->send('[email protected]', $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); 
} 

나는 (는) 교체 된 코드를 다시 추가하기 위해 PHP 파일을 다시 편집했습니다. 그렇지 않으면 admin의 새로운 주문 전자 메일이 트리거되지 않습니다.

if ($this->is_enabled() && $this->get_recipient()) { 

나는 사용자 정의 체크 아웃 필드 선택에 따라 조건부 전자 메일을 보내려하고있어 두뇌가 고갈되었습니다.

관련 문제