我有一个问题。我有一个短信系统,我想在下订单后在感谢页面上发送短信。现在,我们创建的插件中的示例代码如下所示:
public function thankyou_page() {
if ( $this->instructions ) {
$api_sms = new sms_meli;
$api_sms->send_sms($to, 'Your Order is Accept');
echo wpautop( wptexturize( $this->instructions ) );
}
}
现在我想把$替换为作为买家的手机号码给他发短信。
我认为你应该得到如下的顺序:
$order = wc_get_order($order_id);$phone = $order->get_billing_phone();也许你可以用woocommerce_thankyou钩子添加一个动作:
function send_sms($order_id){
$order = wc_get_order($order_id);
$phone = $order->get_billing_phone();
//do something
}
add_action('woocommerce_thankyou', 'send_sms');
当然,你也应该检查一下电话号码是否是手机号码,以免丢失信息。