【问题标题】:WooCommerce Subscriptions Emails: What are the correct 'woocommerce_email_order_details' hook function arguments (to modify "renewal" emails)?WooCommerce 订阅电子邮件:正确的“woocommerce_email_order_details”挂钩函数参数是什么(修改“续订”电子邮件)?
【发布时间】:2019-12-31 19:26:17
【问题描述】:

我在跟踪“woocommerce_email_order_details”挂钩中的(WooCommerce 订阅特定的)“customer_renewal_invoice”和“processing_renewal_order”电子邮件 ID 的正确挂钩函数参数以修改/添加电子邮件内容时遇到问题。

我对标准的 WooCommerce 订单电子邮件有此工作(即电子邮件内容修改),但根据 LoicTheAztec (Get the email id in Woocommerce emails),订阅插件使用不同的钩子函数参数;我只是不知道那些是什么。

这是我现有的简化版本:

add_action ('woocommerce_email_order_details', 'custom_email_notification', 5, 4);
function custom_email_notification( $order, $sent_to_admin, $plain_text, $email ){
    if ( 'customer_processing_order' == $email->id || 'customer_invoice' == $email->id || 'customer_on_hold_order' == $email->id || 'customer_renewal_invoice' == $email->id || 'processing_renewal_order' == $email->id ){
        echo "Extra content here";
    }
}

前三个“标准”/WooCommerce 电子邮件 ID 正确使用,但后两个(特定于 WooCommerce 订阅插件)从未使用/触发;我知道这是因为我的钩子参数不正确,但我不知道如何更正它们。

我觉得这些其他帖子中提到了我需要的信息的本质,但我不能将所有部分放在一起;按照感知相关性的顺序列出:

https://stackoverflow.com/a/42097450

https://stackoverflow.com/a/31677646

WooCommerce Subscription Cancellation Email to Customer

在 StackOverflow 上的用户提供的难以置信的帮助下,我的生活不断变得更轻松/可以忍受;谢谢大家,并提前感谢您在此问题上提供的任何帮助。

【问题讨论】:

标签: woocommerce hook-woocommerce subscription woocommerce-subscriptions


【解决方案1】:

我认为您可能实际上想要woocommerce_subscriptions_email_order_details,它似乎是从您想要的两封电子邮件中调用的(templates/emails/customer-renewal-invoice.php 和 templates/emails/customer-processing-renewal-order.php) .在这两种情况下,它都会收到$order, $sent_to_admin, $plain_text, $email。但是如果你想处理任何其他情况,有时会在其他地方调用$subscription, $sent_to_admin, $plain_text, $email

【讨论】:

  • 成功了!现在似乎很明显,但我告诉你:我确实事先尝试过自己找到答案。非常感谢;事情终于如期进行了!
  • 哦,我不怪你',关于订阅的文档很薄。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-12
  • 2013-03-11
  • 1970-01-01
  • 2018-03-21
  • 1970-01-01
  • 2014-01-02
  • 1970-01-01
相关资源
最近更新 更多