pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

在 Woocommerce 中重命名多個訂單狀態

Rename multiple order statuses in Woocommerce(在 Woocommerce 中重命名多個訂單狀態)
本文介紹了在 Woocommerce 中重命名多個訂單狀態的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我正在嘗試通過編輯我的主題的 functions.php 文件來重命名多個 WooCommerce 訂單狀態.幾年前我發現這里發布的一些代碼可以更改單個訂單狀態,但是由于我對 php 非常缺乏經驗,我不知道如何擴展它以更改多個狀態.理想情況下,我還想將wc-processing"重命名為Paid",將wc-on-hold"重命名為Pending".

這是我找到的用于編輯單個訂單狀態的代碼:

function wc_renaming_order_status( $order_statuses ) {foreach ( $order_statuses as $key => $status ) {$new_order_statuses[ $key ] = $status;if ('wc-completed' === $key ) {$order_statuses['wc-completed'] = _x('訂單已收到', '訂單狀態', 'woocommerce');}}返回 $order_statuses;}add_filter('wc_order_statuses', 'wc_renaming_order_status');

有人知道我需要進行哪些更改才能更改其他狀態嗎?

解決方案

由于存在 Pending 訂單狀態,您還需要將現有的Pending"重新命名為Pending"地位.如果不是,您將獲得 2 個具有相同待定"的不同狀態.標簽.

首先重命名這些訂單狀態:

add_filter( 'wc_order_statuses', 'rename_order_statuses', 20, 1 );函數 rename_order_statuses( $order_statuses ) {$order_statuses['wc-completed'] = _x('訂單已收到', '訂單狀態', 'woocommerce');$order_statuses['wc-processing'] = _x('付費','訂單狀態','woocommerce');$order_statuses['wc-on-hold'] = _x('Pending', 'Order status', 'woocommerce');$order_statuses['wc-pending'] = _x('等待','訂單狀態','woocommerce');返回 $order_statuses;}

也在批量編輯訂單列表下拉菜單中:

add_filter( 'bulk_actions-edit-shop_order', 'custom_dropdown_bulk_actions_shop_order', 20, 1 );函數 custom_dropdown_bulk_actions_shop_order( $actions ) {$actions['mark_processing'] = __( 'Markpaid', 'woocommerce');$actions['mark_on-hold'] = __( 'Mark pending', 'woocommerce' );$actions['mark_completed'] = __( 'Mark order received', 'woocommerce' );返回 $actions;}

這也是需要的(對于頂部菜單):

foreach( array( 'post', 'shop_order' ) as $hook )add_filter( "views_edit-$hook", 'shop_order_modified_views');功能 shop_order_modified_views( $views ){if( isset( $views['wc-completed'] ) )$views['wc-completed'] = str_replace('Completed', __('Order Received', 'woocommerce'), $views['wc-completed'] );if( isset( $views['wc-processing'] ) )$views['wc-processing'] = str_replace('Processing', __('Paid', 'woocommerce'), $views['wc-processing'] );if( isset( $views['wc-on-hold'] ) )$views['wc-on-hold'] = str_replace('On hold', __('Pending', 'woocommerce'), $views['wc-on-hold'] );if( isset( $views['wc-pending'] ) )$views['wc-pending'] = str_replace('Pending', __('Stucked', 'woocommerce'), $views['wc-pending'] );返回 $views;}

(感謝

代碼位于活動子主題(或活動主題)的 function.php 文件中.經測試有效.

<塊引用>

從 Woocommerce 3.3 開始處理管理訂單列表中的預覽彈出窗口(眼睛符號):

隨處替換訂單狀態名稱包括Woocommerce 管理員訂單預覽

I'm trying to rename multiple WooCommerce order status by editing my theme's functions.php file. I found some code posted here a couple years ago that works to change a single order status, but since I'm very inexperienced with php, I don't know how to expand on it to change multiple statuses. Ideally I'd also like to rename 'wc-processing' to 'Paid' and 'wc-on-hold' to 'Pending'.

Here's the code I found to edit a single order status:

function wc_renaming_order_status( $order_statuses ) {
    foreach ( $order_statuses as $key => $status ) {
        $new_order_statuses[ $key ] = $status;
        if ( 'wc-completed' === $key ) {
            $order_statuses['wc-completed'] = _x( 'Order Received', 'Order status', 'woocommerce' );
        }
    }
    return $order_statuses;
}
add_filter( 'wc_order_statuses', 'wc_renaming_order_status' );

Anyone know what changes I need to make to change additional statuses?

解決方案

As Pending order status exist, you need also to rename the existing "Pending" status. If not you will get 2 different statuses with the same "Pending" label.

First to rename those order statuses:

add_filter( 'wc_order_statuses', 'rename_order_statuses', 20, 1 );
function rename_order_statuses( $order_statuses ) {
    $order_statuses['wc-completed']  = _x( 'Order Received', 'Order status', 'woocommerce' );
    $order_statuses['wc-processing'] = _x( 'Paid', 'Order status', 'woocommerce' );
    $order_statuses['wc-on-hold']    = _x( 'Pending', 'Order status', 'woocommerce' );
    $order_statuses['wc-pending']    = _x( 'Waiting', 'Order status', 'woocommerce' );

    return $order_statuses;
}

And Also in the bulk edit order list dropdown:

add_filter( 'bulk_actions-edit-shop_order', 'custom_dropdown_bulk_actions_shop_order', 20, 1 );
function custom_dropdown_bulk_actions_shop_order( $actions ) {
    $actions['mark_processing'] = __( 'Mark paid', 'woocommerce' );
    $actions['mark_on-hold']    = __( 'Mark pending', 'woocommerce' );
    $actions['mark_completed']  = __( 'Mark order received', 'woocommerce' );

    return $actions;
}

And also this is needed (for the top menu):

foreach( array( 'post', 'shop_order' ) as $hook )
    add_filter( "views_edit-$hook", 'shop_order_modified_views' );

function shop_order_modified_views( $views ){
    if( isset( $views['wc-completed'] ) )
        $views['wc-completed'] = str_replace( 'Completed', __( 'Order Received', 'woocommerce'), $views['wc-completed'] );

    if( isset( $views['wc-processing'] ) )
        $views['wc-processing'] = str_replace( 'Processing', __( 'Paid', 'woocommerce'), $views['wc-processing'] );

    if( isset( $views['wc-on-hold'] ) )
        $views['wc-on-hold'] = str_replace( 'On hold', __( 'Pending', 'woocommerce'), $views['wc-on-hold'] );

    if( isset( $views['wc-pending'] ) )
        $views['wc-pending'] = str_replace( 'Pending', __( 'Stucked', 'woocommerce'), $views['wc-pending'] );

    return $views;
}

(Thanks to brasofilo : Change WP admin post status filter for custom post type)

Code goes in function.php file of your active child theme (or active theme). Tested and works.

Since Woocommerce 3.3 to handle the preview popup (eye symbol) in admin order list:

Replace order status names everywhere incl. Woocommerce admin order preview

這篇關于在 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)
主站蜘蛛池模板: 脉冲除尘器,除尘器厂家-淄博机械| 万家财经_财经新闻_在线财经资讯网| 杭州ROHS检测仪-XRF测试仪价格-百科 | 防堵吹扫装置-防堵风压测量装置-电动操作显示器-兴洲仪器 | 云南丰泰挖掘机修理厂-挖掘机维修,翻新,再制造的大型企业-云南丰泰工程机械维修有限公司 | 广东成考网-广东成人高考网 | 分光色差仪,测色仪,反透射灯箱,爱色丽分光光度仪,美能达色差仪维修_苏州欣美和仪器有限公司 | 无锡网站建设_企业网站定制-网站制作公司-阿凡达网络 | 干粉砂浆设备_干混砂浆生产线_腻子粉加工设备_石膏抹灰砂浆生产成套设备厂家_干粉混合设备_砂子烘干机--郑州铭将机械设备有限公司 | 长沙印刷厂-包装印刷-画册印刷厂家-湖南省日大彩色印务有限公司 青州搬家公司电话_青州搬家公司哪家好「鸿喜」青州搬家 | 光纤测温-荧光光纤测温系统-福州华光天锐光电科技有限公司 | 报警器_家用防盗报警器_烟雾报警器_燃气报警器_防盗报警系统厂家-深圳市刻锐智能科技有限公司 | 无压烧结银_有压烧结银_导电银胶_导电油墨_导电胶-善仁(浙江)新材料 | 快速卷帘门_硬质快速卷帘门-西朗门业 | 深圳标识制作公司-标识标牌厂家-深圳广告标识制作-玟璟广告-深圳市玟璟广告有限公司 | 安规_综合测试仪,电器安全性能综合测试仪,低压母线槽安规综合测试仪-青岛合众电子有限公司 | 东莞猎头公司_深圳猎头公司_广州猎头公司-广东万诚猎头提供企业中高端人才招聘服务 | 「阿尔法设计官网」工业设计_产品设计_产品外观设计 深圳工业设计公司 | 土壤养分检测仪|土壤水分|土壤紧实度测定仪|土壤墒情监测系统-土壤仪器网 | 河南空气能热水器-洛阳空气能采暖-洛阳太阳能热水工程-洛阳润达高科空气能商行 | 江苏密集柜_电动_手动_移动_盛隆柜业江苏档案密集柜厂家 | 上海小程序开发-小程序制作-上海小程序定制开发公司-微信商城小程序-上海咏熠 | Magnescale探规,Magnescale磁栅尺,Magnescale传感器,Magnescale测厚仪,Mitutoyo光栅尺,笔式位移传感器-苏州连达精密量仪有限公司 | 不锈钢螺丝 - 六角螺丝厂家 - 不锈钢紧固件 - 万千紧固件--紧固件一站式采购 | TPE_TPE热塑性弹性体_TPE原料价格_TPE材料厂家-惠州市中塑王塑胶制品公司- 中塑王塑胶制品有限公司 | 成都LED显示屏丨室内户外全彩led屏厂家方案报价_四川诺显科技 | 【北京写字楼出租_写字楼租赁_办公室出租网/出售】-远行地产官网 | 100_150_200_250_300_350_400公斤压力空气压缩机-舰艇航天配套厂家 | 拖鞋定制厂家-品牌拖鞋代加工厂-振扬实业中国高端拖鞋大型制造商 | 千淘酒店差旅平台-中国第一家针对TMC行业的酒店资源供应平台 | 国资灵活用工平台_全国灵活用工平台前十名-灵活用工结算小帮手 | 小学教案模板_中学教师优秀教案_高中教学设计模板_教育巴巴 | 心肺复苏模拟人|医学模型|急救护理模型|医学教学模型上海康人医学仪器设备有限公司 | 喷砂机厂家_自动喷砂机生产_新瑞自动化喷砂除锈设备 | 镀锌方管,无缝方管,伸缩套管,方矩管_山东重鑫致胜金属制品有限公司 | 威廉希尔WilliamHill·足球(中国)体育官方网站 | 造价工程师网,考试时间查询,报名入口信息-网站首页 | 无负压供水设备,消防稳压供水设备-淄博创辉供水设备有限公司 | 艺术生文化课培训|艺术生文化课辅导冲刺-济南启迪学校 | 纯水电导率测定仪-万用气体检测仪-低钠测定仪-米沃奇科技(北京)有限公司www.milwaukeeinst.cn 锂辉石检测仪器,水泥成分快速分析仪-湘潭宇科分析仪器有限公司 手术室净化装修-手术室净化工程公司-华锐手术室净化厂家 | 精密钢管,冷拔精密无缝钢管,精密钢管厂,精密钢管制造厂家,精密钢管生产厂家,山东精密钢管厂家 |