woocommerce return中get_attachments( )函数的数组格式是什么?
$this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(),$this->get_attachments());发布于 2019-02-25 19:06:45
/**
* Get email attachments.
*
* @return array
*/
public function get_attachments() {
return apply_filters( 'woocommerce_email_attachments', array(), $this->id, $this->object );
}如果没有添加任何内容,它将返回一个空数组。用于添加附件的示例代码片段
add_filter( 'woocommerce_email_attachments', 'conditions_pdf_to_email', 10, 3);
function conditions_pdf_to_email ( $attachments, $status , $order ) {
$allowed_statuses = array( 'new_order',);
if( isset( $status ) && in_array ( $status, $allowed_statuses ) ) {
$your_pdf_path = get_template_directory() . '/terms.pdf';
$attachments[] = $pdf_path;
}
return $attachments;
}https://stackoverflow.com/questions/54853193
复制相似问题