問題描述
我想將 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 訂單狀態的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!