0
我正在使用SMS API將短信發送到woocommerce的Thankyou頁面上的客戶。在發送SMS之後,API重定向到API提供的頁面。我問他們一個解決方案,他們建議使用iframe。但重定向存在。然後,他們建議從頁面結帳中調用變量。我無法理解。請引導我。這裏是我的代碼。Woocommerce在thankyou上加載外部頁面
function tz_send_message_to_customer($order_id){
$order = new WC_Order($order_id);
$currency = $order->get_order_currency();
$total = $order->get_total();
$date = $order->order_date;
$name = $order->billing_first_name . $order->billing_last_name;
// Configuration variables
$id = "xxxxx"; // Account Username
$pass = "xxxx"; // Account Password
$mask = "xxxx"; // Account Masking
// Data for text message
$to = $order->billing_phone; // Recipient Number with "92" Pakistan Code
$message = urlencode("Dear " . $name . "!" . "Your following Order is Under Process" . "Order ID: " .$order_id . "Total: " . $currency.$total. "Thankyou For Shopping") ;
// Prepare data for POST request - DO NOT EDIT
$data = "id=".$id."&pass=".$pass."&msg=".$message."&to=".$to."&lang=English"."&mask=".$mask."&type=xml";
// Send the POST request with cURL - DO NOT EDIT
//header("location:http://ip-address/api/sendsms.php?".$data);
$url = "http://ip-address/api/sendsms.php?".$data;
?>
<iframe src="<?php echo $url; ?>"></iframe>
<?php
}
add_action('woocommerce_thankyou', 'tz_send_message_to_customer', 10, 1);