2017-07-06 103 views
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); 

回答

1

我找到了在Google上搜索的解决方案。有人建议在iframe中使用sandbox属性,如sandbox =“allow-same-origin”。因此,iframe的代码看起来像作为

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

更多信息,可以发现:https://www.html5rocks.com/en/tutorials/security/sandboxed-iframes/

相关问题