Woocommerce에서 이메일 ID를 가진 특정 이메일 수신처 지정
Woocommerce에 커스텀 상태와 커스텀 메일이 설정되어 있습니다.저는 지금 메일을 사용하고 싶습니다만,WC_Email
이메일 템플릿 내의 변수로서의 현재 상태가 아닙니다.
이메일 템플릿에 if 문장이 필요합니다.오더로부터의 이메일이 수동으로 재발송되는 경우, 현재의 오더 상태의 데이터를 다른 메일로 송신하지 않도록 하기 위해서, 오더 상태를 사용하고 있지 않습니다.
에코는 어떻게 해야 하나요?WC_Email
이메일 ID를 Woocommerce의 변수로 사용할 수 있습니까?
그wc_order_email
클래스나 기능이 WooCommerce에 존재하지 않아 질문을 업데이트했습니다.
지금 보고 있는 건$email
variable 인수(현재 유형 객체).대부분 템플릿과 후크에 정의되어 있습니다.
사용할 수 있는 현재 이메일 ID를 변수로 가져오려면 다음과 같이 하십시오.$email_id = $email->id
…
커스텀 이메일의 최신 E-메일 ID를 취득하려면 , 다음의 코드를 사용해 주세요(테스트 전용).
add_action( 'woocommerce_email_order_details', 'get_the_wc_email_id', 9, 4 );
function get_the_wc_email_id( $order, $sent_to_admin, $plain_text, $email ) {
// Will output the email id for the current notification
echo '<pre>'; print_r($email->id); echo '</pre>';
}
코드가 기능합니다.php 파일 또는 임의의 플러그인 파일에 있는 활성 자식 테마(또는 테마)입니다.
다음과 같은 메시지가 표시됩니다.
new_order
customer_on_hold_order
customer_processing_order
customer_completed_order
customer_refunded_order
customer_partially_refunded_order
cancelled_order
failed_order
customer_reset_password
customer_invoice
customer_new_account
customer_note
커스텀 이메일 알림에 대한 올바른 이메일 ID 슬러그를 얻으면 이메일 템플릿을 덮어쓰는 대신 다음 후크에서 사용할 수 있습니다.
•woocommerce_email_header
(2개의 인수:$email_heading
,$email
)
•woocommerce_email_order_details
(4개의 인수:$order
,$sent_to_admin
,$plain_text
,$email
)
•woocommerce_email_order_meta
(4개의 인수:$order
,$sent_to_admin
,$plain_text
,$email
)
•woocommerce_email_customer_details
(4개의 인수:$order
,$sent_to_admin
,$plain_text
,$email
)
•woocommerce_email_footer
(1개의 인수:$email
)
여기에서는, 「새로운 주문」의 전자 메일 통지만을 대상으로 하는 코드의 예를 나타냅니다.
add_action( 'woocommerce_email_order_details', 'add_custom_text_to_new_order_email', 10, 4 );
function add_custom_text_to_new_order_email( $order, $sent_to_admin, $plain_text, $email ) {
// Only for "New Order" email notifications (to be replaced by yours)
if( ! ( 'new_order' == $email->id ) ) return;
// Display a custom text (for example)
echo '<p>'.__('My custom text').'</p>';
}
코드가 기능합니다.php 파일 또는 임의의 플러그인 파일에 있는 활성 자식 테마(또는 테마)입니다.
테스트 및 동작.
언급URL : https://stackoverflow.com/questions/47741577/targeting-specific-email-with-the-email-id-in-woocommerce
'programing' 카테고리의 다른 글
여러 양식을 함께 일련화하시겠습니까? (0) | 2023.03.09 |
---|---|
텍스트/보통보다 어플리케이션/json을 사용하는 장점이 있습니까? (0) | 2023.03.09 |
react-router 4 및 styled-component in react를 사용할 때는 라우터 외부에서 Route 또는 withRouter()를 사용하지 마십시오. (0) | 2023.03.09 |
잭슨과의 불변의 롬복 주석 클래스 (0) | 2023.03.09 |
create-react-app은 언제 코드를 난독화 또는 최소화합니까? (0) | 2023.03.04 |