首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >woocommerce中的get_attachments( )

woocommerce中的get_attachments( )
EN

Stack Overflow用户
提问于 2019-02-24 23:02:48
回答 1查看 192关注 0票数 0

woocommerce return中get_attachments( )函数的数组格式是什么?

代码语言:javascript
复制
$this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(),$this->get_attachments());
EN

回答 1

Stack Overflow用户

发布于 2019-02-25 19:06:45

代码语言:javascript
复制
/**
 * Get email attachments.
 *
 * @return array
 */
public function get_attachments() {
    return apply_filters( 'woocommerce_email_attachments', array(), $this->id, $this->object );
}

如果没有添加任何内容,它将返回一个空数组。用于添加附件的示例代码片段

代码语言:javascript
复制
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;
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54853193

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档