2016-09-28 3 views
2

다른 독일어 개발자가 작성한 woocommerce 용 테마로 작업하고 있습니다. 나는 아이 테마를 만들고 아이 테마의 functions.php를 사용하여 웹 사이트의 기능을 변경했다.전자 메일 알림 템플릿에서 고객 세부 정보 및 주소 제거

고객이 제품을 주문하면 주문 표, 고객 정보 및 청구서 수신 주소와 고객 운송이 포함 된 전자 메일을받습니다. 테이블 아래의 모든 것을 제거하고 내 텍스트 (고객 정보 + 대금 청구, 배송 및 주소 선택)를 추가하고 싶습니다.

고객에게 발송되는 이메일의 주문 표 바로 아래에 본인의 텍스트가 추가되었지만, 기본적으로 내 맞춤 텍스트 아래에 표시된 정보는 삭제할 수 없습니다. 나는 가져 오기에 대한 책임이있는 훅을 찾고 그 데이터가 woocommerce_email_order_meta임을 보여 주었지만 그것을 제거하거나 실행을 막을 방법을 모른다. 나는 템플릿 파일을 변경하고 싶지 않고, 모든 것을 후크로하고 싶다.

remove_action('woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email); 

나는 링크를 따라 :

은 지금까지 나는 다음과 같이 그 일을 시도 Delete order info section from email template in woocommerce뿐만 아니라 다음 코드를 시도 을하지만를 작동하지 않았다.

function so_39251827_remove_order_details($order, $sent_to_admin, $plain_text, $email){ 
    $mailer = WC()->mailer(); // get the instance of the WC_Emails class 
    remove_action('woocommerce_email_order_details', array($mailer, 'order_details'), 10, 4); 
} 
add_action('woocommerce_email_order_details', 'so_39251827_remove_order_details', 5, 4); 

어떻게하면됩니까? -

감사

답변

6

설명 모든 전자 메일 알림 템플릿에서 당신이 가지고 : 나는 성공적으로 고객의 세부 사항을 제거한 WooCommerce 코어 파일에 약간의 연구와 몇 가지 테스트 후

/** 
* @hooked WC_Emails::customer_details() Shows customer details 
* @hooked WC_Emails::email_address() Shows email address 
*/ 
do_action('woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email); 

을 청구 원하는대로 알림 이메일에서 주소를 보내십시오. 어떤 플러그인 파일도

function removing_customer_details_in_emails($order, $sent_to_admin, $plain_text, $email){ 
    $mailer = WC()->mailer(); 
    remove_action('woocommerce_email_customer_details', array($mailer, 'customer_details'), 10, 4); 
    remove_action('woocommerce_email_customer_details', array($mailer, 'email_addresses'), 20, 4); 
} 
add_action('woocommerce_email_customer_details', 'removing_customer_details_in_emails', 5, 4); 

이 코드는 활성 자식 테마 (또는 테마)의 function.php 파일에 간다 나 : 여기

는 코드입니다.

이 코드는 테스트를 거쳐 완전히 작동합니다.


참고 :

+0

와우! 작동 중! 고마워요! 신의 축복이 있기를! – Yogie

+0

LoicTheAztec 도움을 다시 주셔서 감사 드리며 프로젝트를 성공적으로 마칠 수있었습니다. 하지만 지금은 배우고 싶습니다. 어떻게 멀리까지 도달 했습니까? 얼마나 정확히 당신 연구를 했습니까? 'woocommerce_email_customer_details' 훅이 아니라'woocommerce_email_order_meta'라는 것을 어떻게 알게 되었습니까? 그런 다음'array ($ mailer, 'customer_details')'인수를 어떻게 찾았습니까? WC() -> mailer()가하는 일을 어떻게 찾았습니까? 제발, 내가 어디에서 평신도의 용어로 이것들을 배울 수 있는지, 나는 아주 woocommerce에서 새롭다. 감사!! – Yogie