附加PDF woocommerce电子邮件 [英] attach PDF woocommerce email
问题描述
我想将PDF附加到Woocommerce的客户处理订单中,我尝试了以下操作:
I would like to attach a PDF to the customer-processing-order from Woocommerce, I have tried the following:
add_filter('woocommerce_email_attachments', 'attach_terms_conditions_pdf_to_email', 10, 3);
function attach_terms_conditions_pdf_to_email ( $attachments, $status , $order ) {
$allowed_statuses = array('customer_processing_order');
if( isset( $status ) && in_array ( $status, $allowed_statuses ) ) {
$your_pdf_path = get_template_directory() . '/terms.pdf';
$attachments[] = $pdf_path;
}
return $attachments;
}
,并且我已将名为terms.pdf的PDF上传到我的子主题中,因此路径为
/wp-content/themes/child-theme/terms.pdf
,但不起作用.有人可以帮忙吗?
and I have uploaded a PDF called terms.pdf into my child theme so path is
/wp-content/themes/child-theme/terms.pdf
, but is not working. Can anyone help?
推荐答案
您正在生成PDF的路径,并将其分配给名为$your_pdf_path
的变量,然后将变量添加到名为$pdf_path
的$attachments
数组中>.您可以简化此过程,而无需使用如下临时变量:
You are generating the path to your PDF and assigning it to a variable named $your_pdf_path
but then you add a variable to the $attachments
array called $pdf_path
. You can simplify this without using a temporary variable like so:
$attachments[] = get_stylesheet_directory() . '/terms.pdf';
这篇关于附加PDF woocommerce电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!