我试图在前端更新客户的结算明细。我有下面的代码:wc_update_order()不按预期方式工作
if(isset($_POST['save_order'])){
$update_billing_details = wc_update_order(array('order_id' => $update_order_id));
$update_order_args = array(
'first_name' => $_POST['billing_first_name']
);
$update_billing_details->set_address($update_order_args, 'billing');
if($update_billing_details){
echo "success";
}
}
会发生什么是,第一个名字是在点击保存按钮TWICE后更新。
例子:
原名为 '约翰'。如果我把它做成'约翰尼'并且保存,它仍然显示'约翰'。如果我输入名称'Johndel',然后点击保存,它会变成'Johnny',依此类推。
但是,如果我做我的代码是这样的:
if(isset($_POST['save_order'])){
$update_order_args = array(
'_billing_first_name' => $_POST['billing_first_name'],
'order_id' => $update_order_id
);
$update_billing_details = wc_update_order($update_order_args);
}
没有发生的事情。
我在做什么错?我根据我的工作通过this question。
任何帮助,高度赞赏。
感谢,
-Eli