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

創建訂單從處理到待處理時設置 WooCommerce 訂單狀

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

問題描述

限時送ChatGPT賬號..

創建 woocommerce 訂單后,訂單狀態為正在處理".我需要將默認訂單狀態更改為待處理".

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?

推薦答案

默認訂單狀態由支付方式或支付網關設置.

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

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

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' );
}

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

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

對于貨到付款付款方式,可以使用專用過濾器鉤子進行調整,請參閱:
貨到付款默認訂單狀態為暫停"而不是處理"在 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

現在您可以更新訂單狀態使用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 會在每次收到訂單頁面加載時觸發,因此需要小心使用...
現在上面的函數只會在第一次更新訂單狀態.如果客戶重新加載頁面,IF 語句中的條件將不再匹配,其他任何事情都不會發生.

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:自動完成支付訂單(取決于付款方式)

這篇關于創建訂單從處理到待處理時設置 WooCommerce 訂單狀態的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)
主站蜘蛛池模板: 久久精品91久久久久久再现 | 久久久精品网站 | 中文字幕在线视频免费观看 | 国产精品美女久久久 | 欧美一区二区三区国产精品 | 久久久久久久久久久久91 | 国产一区二区三区精品久久久 | 伊人国产精品 | 国产精品美女久久久久久免费 | 丁香六月激情 | 国产亚洲一区二区在线观看 | 日韩精品一区二区三区中文在线 | 色综合久久88色综合天天 | 久草在线视频中文 | 久久与欧美| 精品一区二区三 | 久久久久久久久久久高潮一区二区 | 久久久精品 | 日韩中文字幕免费在线观看 | 国产精品黄色 | 精品久久九九 | 久久久久国产一区二区三区四区 | 久久久av中文字幕 | 日本精品一区二区三区四区 | 精品免费国产 | 色在线免费 | 成人做爰www免费看视频网站 | 91影院在线观看 | 日韩在线一区二区三区 | 亚洲不卡一 | 麻豆精品国产91久久久久久 | 玖玖操 | av午夜激情 | 国产乱精品一区二区三区 | 国产日产精品一区二区三区四区 | 91av视频在线播放 | 自拍视频国产 | 成人国产在线视频 | 色综合久 | 成人国产精品免费观看 | 亚洲综合色丁香婷婷六月图片 |