久久久久久久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)
主站蜘蛛池模板: 91影视| 国产精品久久一区 | 祝你幸福电影在线观看 | 一级免费毛片 | 久久久www成人免费无遮挡大片 | 免费视频一区二区三区在线观看 | 一区二区伦理电影 | 一区二区高清 | 国产精品性做久久久久久 | 亚洲品质自拍视频网站 | 午夜婷婷激情 | 欧美高清视频在线观看 | 久久久久久久久久久成人 | 亚洲精品视频在线 | 国产日韩一区二区三免费高清 | a国产一区二区免费入口 | 91免费版在线 | 日韩欧美精品一区 | 欧美色人| 国产一区2区 | 国产色在线 | 国产视频第一页 | 免费观看羞羞视频网站 | 亚洲国产视频一区 | 免费激情网站 | 国产在线观看福利 | 99精品国产一区二区三区 | 免费视频二区 | 久久精品视频网站 | 日本免费视频 | 久久久久久毛片免费观看 | 国产1区2区3区 | 激情小视频| 日韩一区二区视频 | 天天拍天天草 | 免费一区二区三区 | 久久久精品影院 | 国产精品久久久久久亚洲调教 | 91大片| 亚洲成av | 午夜影视 |