【发布时间】:2018-01-20 22:07:18
【问题描述】:
在 WooCommerce 中,当我的网店收到新订单时,我正在运行一个脚本。此脚本向我发送一条短信,但我也想将其发送给客户。
脚本正在使用自定义函数脚本运行,就在包含订单信息的已收到订单页面之前。
如何从订单中获取有关用户使用的姓名和电话号码的自动信息?
阅读这个:How to get WooCommerce order details帖子,对我没有帮助,我可以得到我需要的信息并且我尝试时订单页面失败......
我今天的代码是这样的:
add_action( 'template_redirect', 'wc_custom_redirect_after_purchase' );
function wc_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
// Query args
$query21 = http_build_query(array(
'token' => 'My-Token',
'sender' => 'medexit',
'message' => 'NEW ORDER',
'recipients.0.msisdn' => 4511111111,
));
// Send it
$result21 = file_get_contents('https://gatewayapi.com/rest/mtsms?' . $query21);
// exit;
}
}
我需要的是获取消息中包含的名字。
我想要类似的东西:
$firstname = $order_billing_first_name = $order_data['billing']['first_name'];
$phone = $order_billing_phone = $order_data['billing']['phone'];
但似乎没有什么对我有用。
【问题讨论】:
标签: php wordpress woocommerce sms orders