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

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

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

問(wèn)題描述

限時(shí)送ChatGPT賬號(hào)..

創(chuàng)建 woocommerce 訂單后,訂單狀態(tài)為正在處理".我需要將默認(rèn)訂單狀態(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".

我怎樣才能做到這一點(diǎn)?

How can I achieve this?

推薦答案

默認(rèn)訂單狀態(tài)由支付方式或支付網(wǎng)關(guān)設(shè)置.

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

您可以嘗試使用此自定義掛鉤函數(shù),但它不起作用 (因?yàn)榇藪煦^在付款方式和支付網(wǎng)關(guān)之前被觸發(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' );
}

顯然,每種支付方式(和支付網(wǎng)關(guān))都在設(shè)置訂單狀態(tài)(取決于支付網(wǎng)關(guān)的交易響應(yīng))......

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

對(duì)于貨到付款付款方式,可以使用專(zhuān)用過(guò)濾器鉤子進(jìn)行調(diào)整,請(qǐng)參閱:
貨到付款默認(rèn)訂單狀態(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

現(xiàn)在您可以更新訂單狀態(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' );
}

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

經(jīng)過(guò)測(cè)試并有效

注意:鉤子 woocommerce_thankyou 會(huì)在每次收到訂單頁(yè)面加載時(shí)觸發(fā),因此需要小心使用...
現(xiàn)在上面的函數(shù)只會(huì)在第一次更新訂單狀態(tài).如果客戶重新加載頁(yè)面,IF 語(yǔ)句中的條件將不再匹配,其他任何事情都不會(huì)發(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.

<小時(shí)>

相關(guān)主題:WooCommerce:自動(dòng)完成支付訂單(取決于付款方式)

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

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

相關(guān)文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產(chǎn)品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產(chǎn)品的總訂單數(shù))
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗(yàn)證問(wèn)題中添加自定義注冊(cè)字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡(jiǎn)單產(chǎn)品中添加一個(gè)將更改價(jià)格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產(chǎn)品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結(jié)帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 成人亚洲精品久久久久软件 | 秋霞a级毛片在线看 | 精品日韩在线 | 最近免费日本视频在线 | 成人黄色av网站 | 玖玖操| 午夜影院在线观看免费 | 日韩伦理一区二区三区 | 免费观看一级特黄欧美大片 | 久久久人成影片一区二区三区 | 99精品国产一区二区青青牛奶 | 高清久久久 | 亚洲精品1| 国产一级在线 | 波多野结衣一区二区三区在线观看 | 精品久久久久久久 | 欧美一区二区激情三区 | 欧美乱操| 99精品国产一区二区三区 | 国产精品一区在线观看 | 亚洲精彩视频 | 免费黄色成人 | 色综合激情 | 一区二区三区影院 | 国产乱码精品一区二区三区忘忧草 | 在线观看视频中文字幕 | 99国产精品一区二区三区 | 国产一级一级 | 日韩一区二区三区在线 | 成人国内精品久久久久一区 | 久久99精品久久 | www.一级毛片 | 青娱乐国产 | 精品久久久久久久久亚洲 | 日韩中文一区二区三区 | 成人影音| 男女啪啪高潮无遮挡免费动态 | 日日噜噜噜夜夜爽爽狠狠视频97 | 91在线视频网址 | 中文天堂在线一区 | 欧美国产视频 |