2

WooCommerce では、バイクやスクーターのレンタル サービスの予約を処理する特別なテーマを使用しています。注文関連のデータを取得したい。completedon holdpendingおよび **のprocessing**注文ステータスの電子メール通知が顧客に送信されたときに、SMS を送信しようとしています。

たとえば、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 個のエラーか、何も起こらなかっただけです。

助けてください。

ありがとう

4

1 に答える 1