简体   繁体   English

在 Woocommerce 3.3 中下订单后向客户发送暂停订单通知

[英]Send customer on-hold order notification once order is placed in Woocommerce 3.3

I have this issue.我有这个问题。 I using Woocommerce 3.3.3 in this moment in my site and noticed one weird issue.我现在在我的网站上使用 Woocommerce 3.3.3 并注意到一个奇怪的问题。 After customer placed order, their order is stuck on "On Hold" into Woocommerce orders.客户下订单后,他们的订单被卡在“暂停”状态到 Woocommerce 订单中。

保持状态

and customer dont get any order confirmation mail.并且客户没有收到任何订单确认邮件。 When go to order and move status on order from "On Hold" to "Processing" customer is getting Order Confirmation mail, that should be automatically.当转到订单并将订单状态从“暂停”移动到“处理中”时,客户收到订单确认邮件,这应该是自动的。 Searched, and found this " fix ":搜索,发现这个“修复”:

add_filter( ‘woocommerce_defer_transactional_emails’, ‘__return_false’ );

to be placed into functions.php, but seems that dont changed nothing.被放入functions.php,但似乎没有改变什么。 Anyone with similar issue?有人有类似问题吗?

Try the following instead:请尝试以下操作:

add_action('woocommerce_new_order', 'new_order_on_hold_notification', 30, 1 );
function new_order_on_hold_notification( $order_id ) {
    $order = wc_get_order( $order_id );

    // Only for on hold new orders
    if( ! $order->has_status('on-hold') )
        return; // Exit

    // Send Customer On-Hold Order notification
    WC()->mailer()->get_emails()['WC_Email_Customer_On_Hold_Order']->trigger( $order_id );
}

To change "on-hold" paid orders to "processing" use that:要将“暂停”已付款订单更改为“正在处理”,请使用:

add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_prrocessing_paid_order', 10, 1 );
function custom_woocommerce_auto_prrocessing_paid_order( $order_id ) {
    if ( ! $order_id )
       return;

    $order = wc_get_order( $order_id );

    // No updated 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', '' ) ) ) {
        return;
    } 
    // "Processing" updated status for paid Orders with all others payment methods
    else {
        if( $order->has_status('on-hold') )
            $order->update_status( 'processing' );
    }
}

Code goes in function.php file of your active child theme (or active theme).代码位于活动子主题(或活动主题)的 function.php 文件中。 It should work.它应该工作。

Just to point out:只是要指出:

The solution @LoicTheAztec mentioned works: @LoicTheAztec 提到的解决方案有效:

add_action('woocommerce_new_order', 'new_order_on_hold_notification', 30, 1 );
function new_order_on_hold_notification( $order_id ) {
    $order = wc_get_order( $order_id );

    // Only for on hold new orders
    if( ! $order->has_status('on-hold') )
        return; // Exit

    // Send Customer On-Hold Order notification
    WC()->mailer()->get_emails()['WC_Email_Customer_On_Hold_Order']->trigger( $order_id );
}

However there's an issue with this solution, at the time woocommerce_new_order hook is called the order hasn't been fully created yet, so as result in the email notification the order items are not displayed.但是,此解决方案存在一个问题,在调用woocommerce_new_order挂钩时,订单尚未完全创建,因此在电子邮件通知中未显示订单项目。 Use the following hook instead:请改用以下钩子:

    add_action('woocommerce_checkout_order_processed', 'new_order_on_hold_notification');   
    function new_order_on_hold_notification( $order_id ) {
                    $order = wc_get_order( $order_id );

                    // Only for on hold new orders
                    if( ! $order->has_status('on-hold') )
                        return; // Exit

                    // Send Customer On-Hold Order notification
                    WC()->mailer()->get_emails()['WC_Email_Customer_On_Hold_Order']->trigger( $order_id );
     }

At the time woocommerce_checkout_order_processed is called the order items are already available for your email.woocommerce_checkout_order_processed被调用时,订单项目已经可用于您的电子邮件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 发送有关保留的Woocommerce订单的客户处理订单电子邮件通知 - Send customer processing order email notification for on-hold Woocommerce orders 在 Woocommerce 中获取客户“暂停”订单状态总金额 - Get customer "on-hold" order status total amount in Woocommerce 使暂停订单状态通知在 Woocommerce 中工作 - Make On-hold order status notification working in Woocommerce 向管理员发送暂停订单状态 email 通知 - Send on-hold order status email notification to admin 从 WooCommerce“暂停订单”和“新订单”电子邮件中删除订单编号 - Remove Order # from WooCommerce “Order on-hold” & “New Order” Emails 在Woocommerce中发送具有暂停状态的COD订单的电子邮件通知 - Send email notification for COD orders with on-hold status in Woocommerce 以编程方式重新发送WooCommerce customer_on_hold_order电子邮件通知 - Resend programmatically a WooCommerce customer_on_hold_order email notification 在 Woocommerce 中下订单后,向管理员电子邮件通知添加附件 - Add an attachment to admin email-notification once order is placed in Woocommerce 如何在Woocommerce中自动发送客户发票/订单明细电子邮件通知 - How to send Customer invoice / Order details email notification Automatically In Woocommerce 立即将暂停订单设置为在 WooCommerce 中处理并发送处理电子邮件通知 - Immediately set on-hold orders to processing in WooCommerce and send the processing email notification
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM