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

WooCommerce 中所有現(xiàn)有處理訂單的自動完成狀態(tài)

Auto completed status for all existing processing orders in WooCommerce(WooCommerce 中所有現(xiàn)有處理訂單的自動完成狀態(tài))
本文介紹了WooCommerce 中所有現(xiàn)有處理訂單的自動完成狀態(tài)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時送ChatGPT賬號..

我在 WooCommerce 上使用這個代碼的小和平從這個答案自動完成支付處理訂單:

I am using on WooCommerce this little peace of code from this answer to autocomplete paid processing orders:

/**
 * AUTO COMPLETE PAID ORDERS IN WOOCOMMERCE
 */
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_paid_order', 10, 1 );
function custom_woocommerce_auto_complete_paid_order( $order_id ) {
    if ( ! $order_id ) {
        return;
    }

    $order = wc_get_order( $order_id );

  // No updated status for orders delivered with Bank wire, Cash on delivery and Cheque payment methods.
  if ( ( get_post_meta($order->id, '_payment_method', true) == 'bacs' ) || ( get_post_meta($order->id, '_payment_method', true) == 'cod' ) || ( get_post_meta($order->id, '_payment_method', true) == 'cheque' ) ) {
    return;
    } 
  // "completed" updated status for paid Orders with all others payment methods
    else {
        $order->update_status( 'completed' );
    }
} 

但問題是我通過 SMS 使用了一個特殊的支付網(wǎng)關(guān),該網(wǎng)關(guān)的 API 橋接在cod"付款方式上,并且訂單有時會在此woocommerce_thankyou"掛鉤上處于暫停狀態(tài).

But the problem is that I use a special payment gateway by SMS which API is bridged on 'cod' payment method, and the orders stay sometimes in on-hold status on this 'woocommerce_thankyou' hook.

所以我需要一直掃描正在處理"的訂單,以完整狀態(tài)傳遞它們.我嘗試了不同的東西和鉤子,但我無法按預(yù)期工作.

So I will need to scan all the time the 'processing' orders to pass them in complete status. I have tried different things and hooks, but I cant get it work as expected.

我該怎么做?

謝謝

推薦答案

要使此工作正常運行,您只需要一個小功能即可掃描所有帶有處理"命令的訂單.'init' 鉤子上的狀態(tài),并且會將此狀態(tài)更新為已完成".

To get this working you just need a little function that will scan all orders with a "processing" status on the 'init' hook, and that will update this status to "completed".

代碼如下:

function auto_update_orders_status_from_processing_to_completed(){
    // Get all current "processing" customer orders
    $processing_orders = wc_get_orders( $args = array(
        'numberposts' => -1,
        'post_status' => 'wc-processing',
    ) );
    if(!empty($processing_orders))
        foreach($processing_orders as $order)
            $order->update_status( 'completed' );
}
add_action( 'init', 'auto_update_orders_status_from_processing_to_completed' );

此代碼已經(jīng)過測試且有效.

This code is tested and works.

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

建議和更新

電子郵件通知發(fā)送兩次一個小錯誤在這里解決:
避免在某些自動完成的訂單上重復(fù)發(fā)送電子郵件通知

這篇關(guān)于WooCommerce 中所有現(xiàn)有處理訂單的自動完成狀態(tài)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(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 和電話字段驗證問題中添加自定義注冊字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡單產(chǎn)品中添加一個將更改價格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產(chǎn)品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結(jié)帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 国产精品欧美一区二区三区不卡 | 国产成人在线播放 | 999久久久| 精品一区二区三区在线观看国产 | 日韩一区二区三区视频 | 欧美日韩在线观看一区二区三区 | 精久久久久| 噜噜噜噜狠狠狠7777视频 | av大片在线观看 | 国产午夜精品视频 | 国产黄色一级片 | 亚洲第一网站 | 亚洲天堂av网 | av色站| 玖玖综合在线 | 极品的亚洲 | 国产在线视频一区二区 | 99国产精品久久久久老师 | 狠狠躁天天躁夜夜躁婷婷老牛影视 | 欧美2区| 国产精品永久免费 | 91人人澡人人爽 | 亚洲精品亚洲人成人网 | 欧洲毛片 | 精品视频在线播放 | 成人黄色av网址 | 少妇精品亚洲一区二区成人 | 日韩欧美日韩在线 | 久久久久免费 | 蜜桃综合在线 | 91精品国产一区二区在线观看 | 99视频在线免费观看 | 九色 在线| 99re在线免费视频 | 伊人久久免费 | 羞羞视频在线观看 | 日韩欧美精品在线播放 | 在线视频 欧美日韩 | 超碰精品在线 | 看av网址| 九九福利|