繁体   English   中英

当订单状态发生变化时,将 email 发送给 WordPress 用户?

[英]Send email to WordPress user when Order Status changes?

我正在使用一个名为 RestroPress 的插件——它用于餐厅外卖。

我想创建一个脚本,以便当$order_statuses设置为'ready'时,会将电子邮件发送到特定的 WordPress 用户角色。

这是一个示例代码,其中包括我获得此信息的位置:

function rpress_get_order_statuses() {
    $order_statuses = array(
      'pending'     => __( 'Pending', 'restropress' ),
      'accepted'    => __( 'Accepted', 'restropress' ),
      'processing'  => __( 'Processing', 'restropress' ),
      'ready'       => __( 'Ready', 'restropress' ),
      'transit'     => __( 'In Transit', 'restropress' ),
      'cancelled'   => __( 'Cancelled', 'restropress' ),
      'completed'   => __( 'Completed', 'restropress' ),
    );
    return apply_filters( 'rpress_order_statuses', $order_statuses );
}

关于我如何做到这一点的任何线索?

function send_customer_purchase_notification_ready( $payment_id, $new_status ) {

    $order_status = rpress_get_option( $new_status );

    if ( !empty( $payment_id ) && $new_status !== 'pending' && $new_status == 'ready' ) {                  
        $message = 'Order is ready';
        $to = 'harshitvaishnav612@gmail.com';
        $subject = "Order is ready";
        $headers = ''; 
        //Here put your Validation and send mail
        $sent = wp_mail($to, $subject, strip_tags($message), $headers);
    }
}
add_action( 'rpress_update_order_status', 'send_customer_purchase_notification_ready' , 10, 2 );

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM