[英]Trigger email on order custom status change in Woocommerce
I've created a custom email class and added it to WooCommerce.我创建了一个自定义电子邮件类并将其添加到 WooCommerce。 When I go to the emails setting in WooCommerce I can see my template there and when I trigger it manually the email arrives at the target email account.当我转到 WooCommerce 中的电子邮件设置时,我可以在那里看到我的模板,当我手动触发它时,电子邮件会到达目标电子邮件帐户。 Now I have the problem that I've added a action to my class which should detect the order status change and do my trigger function if the order gets set to my custom status:现在我有一个问题,我在我的类中添加了一个动作,它应该检测订单状态的变化并在订单设置为我的自定义状态时执行我的触发功能:
add_action( 'woocommerce_order_status_wc-test-in-progress', array( $this, 'trigger' ), 10, 10 ); add_action( 'woocommerce_order_status_wc-test-in-progress', array( $this, 'trigger' ), 10, 10 );
But when I change the order to this status I don't receive any email.但是当我将订单更改为此状态时,我没有收到任何电子邮件。 Whats wrong here?这里有什么问题?
https://github.com/woocommerce/woocommerce/blob/master/includes/emails/class-wc-email-customer-on-hold-order.php https://github.com/woocommerce/woocommerce/blob/master/includes/emails/class-wc-email-customer-on-hold-order.php
You can checkout this file.你可以签出这个文件。 I've exactly did the same like in this file but replaced all triggers with my custom trigger on order status change.我在这个文件中做了同样的事情,但在订单状态更改时用我的自定义触发器替换了所有触发器。
Wen using woocommerce_order_status_{$status_transition[to]}
composite hook, you just need to remove wc-
from the status slug like: Wen 使用woocommerce_order_status_{$status_transition[to]}
复合钩子,你只需要从状态slug中删除wc-
,如:
add_action( 'woocommerce_order_status_test-in-progress', array( $this, 'trigger' ), 10, 10 );
And it should work.它应该工作。
I have created a new status for orders along with the email template named "reminder".我为订单创建了一个新状态以及名为“提醒”的电子邮件模板。 Now I want that if I change the status of an order from a reminder to processing the processing email should be sent to the customer.现在我希望如果我将订单的状态从提醒更改为处理处理电子邮件应该发送给客户。 It's not sending now.现在不送了。 I think I might have to modify processing email triggers.我想我可能需要修改处理电子邮件触发器。 Any idea how can I achieve this?知道我怎么能做到这一点吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.