【发布时间】:2018-10-24 10:54:32
【问题描述】:
我正在使用 wordpress 4.9.5 和 woocommerce 3.3.5,我希望触发以下付款方式、订单状态和客户邮件。
- Paypal = 完成 + 付款确认电子邮件
- BACS = 暂停 + 订单暂停电子邮件
- COD = 暂停 + 订单暂停电子邮件
此时一切正常,除了在使用 COD 时没有收到“订单暂停电子邮件”。 订单状态为“暂停”,但暂停邮件未发送!
这是我正在使用的代码:
add_action( 'woocommerce_thankyou', 'wc_auto_complete_paid_order', 20, 1 );
function wc_auto_complete_paid_order( $order_id ) {
if ( ! $order_id )
return;
// Get an instance of the WC_Product object
$order = wc_get_order( $order_id );
// On hold status for orders delivered with Bank wire, Cash on delivery and Cheque payment methods.
if ( in_array( $order->get_payment_method(), array( 'bacs', 'cod', 'cheque', '' ) ) ) {
$order->update_status( 'on-hold' );
// Updated status to "completed" for paid Orders with all others payment methods
} else {
$order->update_status( 'completed' );
}
}
function unhook_new_order_processing_emails( $email_class ) {
// Turn off pending to processing for now
remove_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) );
// Turn it back on but send the on-hold email
add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_Customer_On_Hold_Order'], 'trigger' ) );
}
【问题讨论】:
标签: php wordpress woocommerce orders email-notifications