【问题标题】:WooCommerce pdf attachment to custom email is not working自定义电子邮件的 WooCommerce pdf 附件不起作用
【发布时间】:2021-05-04 07:42:16
【问题描述】:

我正在使用 WooCommerce 订单状态管理器插件来自定义订单状态和电子邮件通知。我已经通过卡支付为已支付订单创建了自定义状态 - card-on-hold
我还创建了自定义电子邮件,当状态从 receivet 更改为 card-on-hold 时将触发。

我的代码是:

add_filter( 'woocommerce_email_attachments', 'attach_manual_pdf_to_email', 10, 3);
    
function attach_manual_pdf_to_email ( $attachments, $status , $order ) {
    
    $allowed_statuses = array( 'customer_processing_order', 'customer_on_hold_order', 'customer_order_status_email' );
    
    if( isset( $status ) && in_array ( $status, $allowed_statuses ) ) {
        $dokument = get_template_directory() . '/woocommerce/emails/attach.pdf';
        $attachments = $dokument;
    }
    return $attachments;
}

电子邮件 ID customer_processing_ordercustomer_on_hold_order 就像一个魅力。

但是customer_order_status_email 是订单状态管理器的 php 模板,它不起作用。它位于betheme/woocommerce/emails/customer-order-status-email.php,我也尝试将它移动到其他模板所在的相同位置,但这没有帮助。

您知道如何使它工作吗?

【问题讨论】:

  • 可能是因为customer_order_status_email不是订单状态而是模板文件名……
  • 是的,我知道这些插件,但我不想在附件中使用发票、装箱单等,根本无法连接到 woocommerce。只是带有手册的简单pdf。
  • LoicTheAztec - 问题可能是我的自定义电子邮件在订单状态从已收到更改为卡保留时触发。我尝试使用 card_on_hold 但它不起作用也尝试了 customer_card_on_hold_order。我不知道那应该是什么状态。

标签: email woocommerce hook attachment status


【解决方案1】:

好的,我确实找到了解决方案:

我确实在电子邮件模板中使用了echo '<pre>'; print_r($email->id); echo '</pre>',它打印了我的电子邮件 ID。我在允许的状态下使用了这个 id,它现在可以工作了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-11
    • 2018-01-20
    • 1970-01-01
    • 1970-01-01
    • 2020-08-31
    • 2016-03-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多