重命名 WooCommerce 订单状态

Renaming WooCommerce Order Status(重命名 WooCommerce 订单状态)
本文介绍了重命名 WooCommerce 订单状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我想将 WooCommerce 订单状态从已完成"重命名为已收到订单".我可以编辑下面位于 wc-order-functions.php 的脚本,但我不想修改任何核心文件或使用插件.

I would like to rename the WooCommerce order status from "Completed" to "Order Received". I can edit the script below located in wc-order-functions.php, but I would prefer not to modify any core files or use a plugin.

是否可以使用子主题的 functions.php 文件中的脚本覆盖 woocoomerce 函数?

Is it possible to override woocoomerce functions with scripts in child theme's functions.php file?

function wc_get_order_statuses() {
  $order_statuses = array(
    'wc-pending'    => _x( 'Pending Payment', 'Order status', 'woocommerce' ),
    'wc-processing' => _x( 'Processing', 'Order status', 'woocommerce' ),
    'wc-on-hold'    => _x( 'On Hold', 'Order status', 'woocommerce' ),
    'wc-completed'  => _x( 'Completed', 'Order status', 'woocommerce' ),
    'wc-cancelled'  => _x( 'Cancelled', 'Order status', 'woocommerce' ),
    'wc-refunded'   => _x( 'Refunded', 'Order status', 'woocommerce' ),
    'wc-failed'     => _x( 'Failed', 'Order status', 'woocommerce' ),
  );
  return apply_filters( 'wc_order_statuses', $order_statuses );
}

推荐答案

只需将订单状态已完成"重命名为已收到订单",这很简单,可以通过 wc_order_statuses 钩子(您将此代码段粘贴到您的活动子主题 function.php 文件中):

Just renaming order status "Completed" to "Order Received", it's easy and can be accomplished this way with wc_order_statuses hook (you will paste this snippet in your active child theme function.php file):

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

代码位于活动子主题(或活动主题)的 function.php 文件中.经测试有效.

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

2018 年更新 - 要重命名,在订单列表页面:
批量操作下拉列表
订单状态标签(带计数)
请参阅:在 Woocommerce 中重命名多个订单状态

Update 2018 - To rename, in Order list page:
the bulk actions dropdown
the order status tabs (with the count)
See: Rename multiple order statuses in Woocommerce

其他相关参考:如何创建自定义woocommerce 中的订单状态

这篇关于重命名 WooCommerce 订单状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Codeigniter htaccess to remove index.php and www(Codeigniter htaccess 删除 index.php 和 www)
htaccess mod_rewrite part of url to GET variable(htaccess mod_rewrite url 的一部分到 GET 变量)
Replacing a querystring parameter value using mod_rewrite(使用 mod_rewrite 替换查询字符串参数值)
.htaccess in subdirectory #39;overriding#39; parent htaccess(子目录“覆盖父 htaccess 中的 .htaccess)
How to rewrite SEO friendly url#39;s like stackoverflow(如何像stackoverflow一样重写SEO友好的url)
Is it okay to have a very long .htaccess file?(有一个很长的 .htaccess 文件可以吗?)