仅将 pdf 附加到 Woocommerce 中的特定电子邮件通知
Attach pdf to only specific email notification in Woocommerce
仅将 pdf 附加到 woocommerce 新订单电子邮件
我正在使用此代码,但 PDF 会附加到 woocommerce 中的每封电子邮件中
add_filter( 'woocommerce_email_attachments', 'attach_terms_conditions_pdf_to_email', 10, 3);
function attach_terms_conditions_pdf_to_email ( $attachments , $email_id, $email_object ) {
$your_pdf_path = get_template_directory() . '/terms123.pdf';
$attachments[] = $your_pdf_path;
return $attachments;
}
更新 2
There is no "New order" notification for customers in Woocommerce… Depending on the payment methods enabled, the notifications to target can be "Customer On Hold Order" or/and Customer Processing Order" (see the section at the end)
以下将为客户暂停订单电子邮件通知启用 PDF 附件:
add_filter( 'woocommerce_email_attachments', 'attach_terms_conditions_pdf_to_email', 10, 3 );
function attach_terms_conditions_pdf_to_email ( $attachments , $email_id, $email_object ) {
// Avoiding errors and problems
if ( ! is_a( $order, 'WC_Order' ) || ! isset( $email_id ) ) {
return $attachments;
}
// Only for "Customer On Hold" email notification (for customer)
if( $email_id === 'customer_on_hold_order' ){
$your_pdf_path = get_template_directory() . '/terms123.pdf';
$attachments[] = $your_pdf_path;
}
return $attachments;
}
代码进入您的活动子主题(活动主题)的 function.php 文件。已测试并有效。
根据您在安装中启用的支付网关,您可以:
1) 您可以使用 "Processing" 电子邮件代替, 替换此行:
if( $email_id === 'customer_on_hold_order' ){
通过这个:
if( $email_id === 'customer_processing_order' ){
2) 您可以同时使用客户 "On Hold" 和 "Processing" 电子邮件, 替换此行:
if( $email_id === 'customer_on_hold_order' ){
通过这个:
if( in_array( $email_id, array( 'customer_on_hold_order', 'customer_processing_order' ) ){
仅将 pdf 附加到 woocommerce 新订单电子邮件
我正在使用此代码,但 PDF 会附加到 woocommerce 中的每封电子邮件中
add_filter( 'woocommerce_email_attachments', 'attach_terms_conditions_pdf_to_email', 10, 3);
function attach_terms_conditions_pdf_to_email ( $attachments , $email_id, $email_object ) {
$your_pdf_path = get_template_directory() . '/terms123.pdf';
$attachments[] = $your_pdf_path;
return $attachments;
}
更新 2
There is no "New order" notification for customers in Woocommerce… Depending on the payment methods enabled, the notifications to target can be "Customer On Hold Order" or/and Customer Processing Order" (see the section at the end)
以下将为客户暂停订单电子邮件通知启用 PDF 附件:
add_filter( 'woocommerce_email_attachments', 'attach_terms_conditions_pdf_to_email', 10, 3 );
function attach_terms_conditions_pdf_to_email ( $attachments , $email_id, $email_object ) {
// Avoiding errors and problems
if ( ! is_a( $order, 'WC_Order' ) || ! isset( $email_id ) ) {
return $attachments;
}
// Only for "Customer On Hold" email notification (for customer)
if( $email_id === 'customer_on_hold_order' ){
$your_pdf_path = get_template_directory() . '/terms123.pdf';
$attachments[] = $your_pdf_path;
}
return $attachments;
}
代码进入您的活动子主题(活动主题)的 function.php 文件。已测试并有效。
根据您在安装中启用的支付网关,您可以:
1) 您可以使用 "Processing" 电子邮件代替, 替换此行:
if( $email_id === 'customer_on_hold_order' ){
通过这个:
if( $email_id === 'customer_processing_order' ){
2) 您可以同时使用客户 "On Hold" 和 "Processing" 电子邮件, 替换此行:
if( $email_id === 'customer_on_hold_order' ){
通过这个:
if( in_array( $email_id, array( 'customer_on_hold_order', 'customer_processing_order' ) ){