本文介紹了WooCommerce - 使用 php 代碼更改訂單狀態(tài)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
我正在嘗試更改 WooCommerce 中的訂單狀態(tài),但到目前為止我沒有遇到任何運氣.$order 實例創(chuàng)建成功(我知道是因為 echo $order->status;
工作正常,$order_id 也是正確的.$order->status = 'pending';
根本沒有改變?nèi)魏螙|西,我不知道為什么.
I am trying to change order status in WooCommerce, but I encountered no luck so far. $order instance is created successfully (I know it because echo $order->status;
works fine, $order_id is also correct. $order->status = 'pending';
simply doesn't change anything, I do not know why.
$order = new WC_Order($order_id);
$order->status = 'pending';
有人能幫我解決這個問題嗎?
Could anyone help me with this?
推薦答案
試試這個代碼:
$order = new WC_Order($order_id);
$order->update_status('pending', 'order_note'); // order note is optional, if you want to add a note to order
這篇關(guān)于WooCommerce - 使用 php 代碼更改訂單狀態(tài)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!