问题描述
我创建了自己的功能,客户可以在订单创建后 4 小时内取消订单。 但是现在我想要的是如果客户不取消订单,物流中心(自定义电子邮件)将收到带有订单详细信息的自定义消息(“订单未取消,您可以继续发货。”)。
我已经为取消按钮编写了此代码,但现在请您改进此代码以实现电子邮件功能。
// Cancel Order Button Inside My Account Order Page
function custom_cancel_button_in_time_limit ( $statuses,$order ){
// Set HERE the order statuses where you want the cancel button to appear
$custom_statuses = array( 'completed','pending','processing','on-hold','Failed' );
// Set HERE the delay (in hours)
$duration = 4; // 4 hours
// UPDATE: Get the order ID and the WC_Order object
if( isset($_GET['order_id']))
$order = wc_get_order( absint( $_GET['order_id'] ) );
// $delay = $duration*24*60*60; // (duration in seconds for days)
$delay = $duration*60*60; // (duration in seconds)
$date_created_time = strtotime($order->get_date_created()); // Creation date time stamp
$date_modified_time = strtotime($order->get_date_modified()); // Modified date time stamp
$Now = strtotime("Now"); // Now time stamp
// Using Creation date time stamp
if ( ( $date_created_time + $delay ) >= $Now ) {
return $custom_statuses;
}
else {
return $statuses;
}
}
add_filter( 'woocommerce_valid_order_statuses_for_cancel','custom_cancel_button_in_time_limit',10,2 );
参考链接
Send a custom reminder email for WooCommerce On-Hold orders after two days
Send custom e-mail after X days WooCommerce order
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)