在WooCommerce中,我尝试仅在订单状态从“处理中”更改为“已完成”(最多2天)时,向客户发送(审阅提醒)电子邮件。 strong>
类似: 如果订单= <2天并且当前订单状态已完成,请发送电子邮件。
add_action("woocommerce_order_status_changed", "customreminder_notification");
function customreminder_notification($order_id, $checkout=null) { global $woocommerce; $order = new WC_Order( $order_id ); $order_date = $order->order_date; $current_date = date('d.m.Y');
if($order->status === 'completed' ) and $order_date = date('d.m.Y',strtotime("-2 days")) {
// Create a mailer
$mailer = $woocommerce->mailer();
$message_body = __( 'Hello customer, please review our service: link.' );
$message = $mailer->wrap_message(
// Message head and message body.
sprintf( __( 'Review reminder' ), $order->get_order_number() ), $message_body );
// Cliente email, email subject and message.
$mailer->send( $order->billing_email, sprintf( __( 'Review reminder' ), $order->get_order_number() ), $message );
}
}