2017-07-06 10 views
0

私はwoocommerceのThankyouページでSMS APIを使用してお客様にSMSを送信しています。 APIは、SMSを送信した後、API提供ページにリダイレクトされます。私は彼らに解決策を尋ね、彼らはiframeの使用を提案した。しかし、リダイレクトが存在します。そして、彼らはページチェックアウトから変数を呼び出すことを提案しました。私は理解できません。親切に、私を案内してください。ここでは、私のコードです。Woocommerceはおかげですページに外部ページを読み込みます

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); 

答えて

1

私はGoogleで検索して解決策を見つけました。 sandbox = "allow-same-origin"のようにiframeにサンドボックス属性を使用することを推奨しました。 https://www.html5rocks.com/en/tutorials/security/sandboxed-iframes/

:だから、IFRAMEコードは、詳細情報はで見つけることができます

<iframe src="<?php echo $url; ?>" sandbox="allow-same-origin" style=" display: none;"></iframe> 

としてのように見えます
関連する問題