久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

創(chuàng)建訂單從處理到待處理時設置 WooCommerce 訂單狀

Set WooCommerce order status when order is created from processing to pending(創(chuàng)建訂單從處理到待處理時設置 WooCommerce 訂單狀態(tài))
本文介紹了創(chuàng)建訂單從處理到待處理時設置 WooCommerce 訂單狀態(tài)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

創(chuàng)建 woocommerce 訂單后,訂單狀態(tài)為正在處理".我需要將默認訂單狀態(tài)更改為待處理".

When a woocommerce order is created the status of the order is "processing". I need to change the default order-status to "pending".

我怎樣才能做到這一點?

How can I achieve this?

推薦答案

默認訂單狀態(tài)由支付方式或支付網關設置.

The default order status is set by the payment method or the payment gateway.

您可以嘗試使用此自定義掛鉤函數,但它不起作用 (因為此掛鉤在付款方式和支付網關之前被觸發(fā)):

You could try to use this custom hooked function, but it will not work (as this hook is fired before payment methods and payment gateways):

add_action( 'woocommerce_checkout_order_processed', 'changing_order_status_before_payment', 10, 3 );
function changing_order_status_before_payment( $order_id, $posted_data, $order ){
    $order->update_status( 'pending' );
}

顯然,每種支付方式(和支付網關)都在設置訂單狀態(tài)(取決于支付網關的交易響應)......

Apparently each payment method (and payment gateways) are setting the order status (depending on the transaction response for payment gateways)…

對于貨到付款付款方式,可以使用專用過濾器鉤子進行調整,請參閱:
貨到付款默認訂單狀態(tài)為暫停"而不是處理"在 Woocommerce

For Cash on delivery payment method, this can be tweaked using a dedicated filter hook, see:
Change Cash on delivery default order status to "On Hold" instead of "Processing" in Woocommerce

現在您可以更新訂單狀態(tài)使用woocommerce_thankyou鉤子:

Now instead you can update the order status using woocommerce_thankyou hook:

add_action( 'woocommerce_thankyou', 'woocommerce_thankyou_change_order_status', 10, 1 );
function woocommerce_thankyou_change_order_status( $order_id ){
    if( ! $order_id ) return;

    $order = wc_get_order( $order_id );

    if( $order->get_status() == 'processing' )
        $order->update_status( 'pending' );
}

代碼位于活動子主題(或主題)的 function.php 文件或任何插件文件中.

經過測試并有效

注意:鉤子 woocommerce_thankyou 會在每次收到訂單頁面加載時觸發(fā),因此需要小心使用...
現在上面的函數只會在第一次更新訂單狀態(tài).如果客戶重新加載頁面,IF 語句中的條件將不再匹配,其他任何事情都不會發(fā)生.

Note: The hook woocommerce_thankyou is fired each time the order received page is loaded and need to be used with care for that reason...
Now the function above will update the order status only the first time. If customer reload the page, the condition in the IF statement will not match anymore and nothing else will happen.

<小時>

相關主題:WooCommerce:自動完成支付訂單(取決于付款方式)

這篇關于創(chuàng)建訂單從處理到待處理時設置 WooCommerce 訂單狀態(tài)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產品的總訂單數)
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗證問題中添加自定義注冊字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡單產品中添加一個將更改價格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 久久久精品一区二区三区四季av | 成人午夜在线 | www四虎影视 | 久久久久久久久久久丰满 | 精品成人 | 国产视频欧美 | 欧美在线视频网 | 天堂网中文| 久久精品二区 | 日本成人综合 | 亚洲欧美精品国产一级在线 | 在线不卡一区 | 一久久久 | 国产激情视频在线观看 | 成人免费视频观看 | 国产精品久久久久久久久久三级 | 久久精品国产清自在天天线 | 亚洲精品一二三 | 亚洲国产精品久久久久秋霞不卡 | 人成精品 | av网站在线播放 | 国产精品一区在线观看 | 国产欧美日韩一区二区三区在线观看 | 欧美精品一区二区免费 | 亚洲精品电影网在线观看 | 亚洲精品九九 | 成人免费福利 | av网站在线播放 | 日韩在线观看精品 | 国产一伦一伦一伦 | 国产高清在线精品一区二区三区 | 成人影院一区二区三区 | 一二三区av | 国产成人99久久亚洲综合精品 | 狠狠av | 亚洲国产精品成人无久久精品 | 欧美三级电影在线播放 | 日本高清精品 | 欧美日韩精品久久久免费观看 | 夜夜操天天艹 | 国产美女福利在线观看 |