我正在尝试添加一项功能,该功能将记录通过订单状态更改发送的所有电子邮件。
在发送定单通知电子邮件之前是否有可以使用的,可以触发的挂钩?
答案 0 :(得分:1)
已更新
负责触发电子邮件通知的所有可用挂钩均位于WC_Emails
init_transactional_emails()
method中,它们是操作挂钩:
woocommerce_low_stock
,woocommerce_no_stock
,woocommerce_product_on_backorder
,woocommerce_order_status_pending_to_processing
,woocommerce_order_status_pending_to_completed
,woocommerce_order_status_processing_to_cancelled
,woocommerce_order_status_pending_to_failed
,woocommerce_order_status_pending_to_on-hold
,woocommerce_order_status_failed_to_processing
,woocommerce_order_status_failed_to_completed
,woocommerce_order_status_failed_to_on-hold
,woocommerce_order_status_on-hold_to_processing
,woocommerce_order_status_on-hold_to_cancelled
,woocommerce_order_status_on-hold_to_failed
,woocommerce_order_status_completed
,woocommerce_order_fully_refunded
,woocommerce_order_partially_refunded
,woocommerce_new_customer_note
,woocommerce_created_customer
。关于新订单通知的最后一点,这有点麻烦,您将使用其中之一:
woocommerce_order_status_pending_to_processing_notification
,woocommerce_order_status_pending_to_completed_notification
,woocommerce_order_status_pending_to_on-hold_notification
,woocommerce_order_status_failed_to_processing_notification
,woocommerce_order_status_failed_to_completed_notification
,woocommerce_order_status_failed_to_on-hold_notification
,如this WC_Email_New_Order
code source中所述。
或者您可以使用status_transition()
WC_Order
method中的3个挂钩之一来检测状态变化:
woocommerce_order_status_changed
woocommerce_order_status_{$status_transition[from]}_to_{$status_transition[to]}
woocommerce_order_status_{$status_transition[to]}
status_transition()
包含在set_status()
WC_Order
method 中(update_status()
method 也是如此set_status()
)。