【问题标题】:Immediately set on-hold orders to processing in WooCommerce and send the processing email notification立即在 WooCommerce 中设置待处理订单并发送处理电子邮件通知
【发布时间】:2021-12-12 12:44:51
【问题描述】:

我需要将所有“暂停”进入的 WooCommerce 订单设置为“正在处理”,并立即发送订单处理电子邮件。

我试过了

function custom_woocommerce_auto_order( $order_id ) {
if ( ! $order_id ) {
    return;
}

$order = wc_get_order( $order_id );
if( 'on-hold'== $order->get_status() ) {
    $order->update_status( 'processing' );
}
}
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_order' );

虽然状态发生了变化,但仍会发送“暂停”电子邮件通知,即使它应该只是“处理中”电子邮件通知。

有什么建议吗?

【问题讨论】:

    标签: php wordpress woocommerce orders email-notifications


    【解决方案1】:

    只要付款未完成,订单就会处于暂停状态。要立即将某些付款方式的默认订单状态更改为处理(并跳过暂停状态)并发送处理电子邮件通知,您可以使用:

    • Bacs - woocommerce_bacs_process_payment_order_status 过滤钩
    • 支票 - woocommerce_cheque_process_payment_order_status 过滤钩
    • 鳕鱼 - woocommerce_cod_process_payment_order_status 过滤钩

    所以你得到:

    function filter_process_payment_order_status( $status, $order ) {
        return 'processing';
    }
    add_filter( 'woocommerce_bacs_process_payment_order_status','filter_process_payment_order_status', 10, 2 );
    add_filter( 'woocommerce_cheque_process_payment_order_status','filter_process_payment_order_status', 10, 2 );
    add_filter( 'woocommerce_cod_process_payment_order_status', 'filter_process_payment_order_status', 10, 2 );
    

    这些过滤器会导致状态更改为所需状态。电子邮件通知将基于此自动发送

    【讨论】:

      猜你喜欢
      • 2018-01-04
      • 2019-12-05
      • 2018-09-19
      • 1970-01-01
      • 1970-01-01
      • 2020-09-22
      • 1970-01-01
      • 2018-01-25
      • 1970-01-01
      相关资源
      最近更新 更多