在woocommerce中,我使用以下代码将PDF文件添加为电子邮件附件:
add_filter( 'woocommerce_email_attachments', 'attach_terms_conditions_pdf_to_email', 10, 3);
function attach_terms_conditions_pdf_to_email ( $attachments , $id, $object ) {
$your_pdf_path1 = get_stylesheet_directory() . '/pdf/ano1.pdf';
$your_pdf_path2 = get_stylesheet_directory() . '/pdf/ano2.pdf';
$attachments[] = $your_pdf_path1;
$attachments[] = $your_pdf_path2;
return $attachments;
}
我的问题是附件总是向所有客户发送电子邮件 . 我想仅在订单状态为“暂停”的情况下发送电子邮件附件 .
如何知道我的订单状态并仅为此案例发送电子邮件附件?
1 回答
更新
您需要将 $id 参数与'customer_on_hold_order'一起用作函数中的电子邮件ID作为条件...
代码放在活动子主题(或主题)的function.php文件中,或者放在任何插件文件中 .
经过测试和工作