在 WooCommerce 中,我使用一个特殊的主题来处理摩托车和踏板车租赁服务的预订。我想获取订单相关数据。我正在尝试在向客户发送电子邮件通知时发送 SMS,以了解、completed
和**订单状态。on hold
pending
processing**
例如,我使用下面的代码在 SMS 中输出我需要的数据:
$order = new WC_Order($order_id);
$status = $order->get_status(); // order status
if( 'completed' == $status || 'processing' == $status || 'pending' == $status || 'on-hold' == $status ){
$user_phone = get_post_meta($order_id, '_billing_phone', true);
foreach ($order->get_items() as $item_id => $item) {
$product_id = $order->get_item_meta($item_id, '_product_id', true); // product ID
$product_name = get_post($product_id)->post_title; // Product description
// Related Booking data to insert in SMS
$book_check_in = $order->get_item_meta( $item_id, '_st_check_in', true );
$book_check_out = $order->get_item_meta( $item_id, '_st_check_out', true );
$book_pick_up = $order->get_item_meta( $item_id, '_st_pick_up', true );
$book_drop_off = $order->get_item_meta( $item_id, '_st_drop_off', true );
}
// Send SMS in SMS API
file_get_contents("http://144.76.39.175/api.php?username=xxxxxxxxxxx&password=xxxxxxxxxxx&route=1&message%5B%5D=The+message&sender=NBWREN&mobile%5B%5D=xxxxxxxxxxx");
}
这是行不通的。我应该在哪里挂钩此代码?我尝试了不同的模板,但我得到的只是大约 500 个错误,或者根本没有发生任何事情。
请给我一些帮助。
谢谢