WooCommerce自动发送已取消的订单电子邮件

时间:2017-03-15 12:54:09

标签: wordpress email woocommerce cancellation

我收到了五封取消通知电子邮件,大约在同一时间,并且没有人取消订单。我打电话给每一个客户,他们都告诉我他们没有取消订单。这些订单实际上并未在Wordpress中取消,但出于某种原因,已发送取消的电子邮件通知。

请帮我解决此问题。

谢谢!

1 个答案:

答案 0 :(得分:0)

add_action("woocommerce_order_status_changed", "my_custom_notification");

function my_custom_notification($order_id, $checkout=null) {
   global $woocommerce;
   $order = new WC_Order( $order_id );
   if($order->status === 'cancelled' ) {
      // Create a mailer
      $mailer = $woocommerce->mailer();

      $message_body = __( 'Hello world!!!' );

      $message = $mailer->wrap_message(
        // Message head and message body.
        sprintf( __( 'Order %s received' ), $order->get_order_number() ), $message_body );

      // Cliente email, email subject and message.
     $mailer->send( $order->billing_email, sprintf( __( 'Order %s received' ), $order->get_order_number() ), $message );
     }

   }

您可以在订单取消时设置自己的通知邮件(订单状态更改为已取消)