随处替换订单状态名称,包括。 Woocommerce 管理员订单预览
Replace order status names everywhere incl. Woocommerce admin order preview
我需要在每个实例中将 "On Hold" 重命名为 "Pending Approval",将 "Processing" 重命名为 "Approved"。 (顺便说一句,我是 diy 店老板,不是开发商)
这个主题让我达到了 60%,
现在需要解决这些位置:
- admin > orders,预览弹出窗口(眼睛符号)。
- 前端 > my-account/orders,状态栏。
- 前端 > my-account/view-order/x,总结行。
我的代码:
add_filter( 'wc_order_statuses', 'rename_order_statuses', 20, 1 );
function rename_order_statuses( $order_statuses ) {
$order_statuses['wc-processing'] = _x( 'Approved', 'Order status', 'woocommerce' );
$order_statuses['wc-on-hold'] = _x( 'Pending Approval', 'Order status', 'woocommerce' );
return $order_statuses;
}
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 Approved', 'woocommerce' );
$actions['mark_on-hold'] = __( 'Mark Pending Approval', 'woocommerce' );
return $actions;
}
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-processing'] ) )
$views['wc-processing'] = str_replace( 'Processing', __( 'Approved', 'woocommerce'), $views['wc-processing'] );
if( isset( $views['wc-on-hold'] ) )
$views['wc-on-hold'] = str_replace( 'On hold', __( 'Pending Approval', 'woocommerce'), $views['wc-on-hold'] );
return $views;
}
你的代码由 答案代码组成,已经涵盖了所有内容 (90%),包括:
前端>my-account/orders,状态栏
前端>my-account/view-order/x,总结行
Otherwise, if it doesn't work, it could be caused by other customizations from you theme, a plugin or your own customizations.
现在要处理 Admin > 订单,预览弹出窗口(眼睛符号) 使用以下代码:
add_filter( 'woocommerce_admin_order_preview_actions', 'filter_admin_order_preview_actions', 10, 2 );
function filter_admin_order_preview_actions( $actions, $order ) {
$actions = array();
$status_actions = array();
if ( $order->has_status( array( 'pending' ) ) ) {
$status_actions['on-hold'] = array(
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=on-hold&order_id=' . $order->get_id() ), 'woocommerce-mark-order-status' ),
'name' => __( 'On-hold', 'woocommerce' ),
'title' => __( 'Change order status to on-hold', 'woocommerce' ),
'action' => 'on-hold',
);
}
if ( $order->has_status( array( 'pending', 'on-hold' ) ) ) {
$status_actions['processing'] = array(
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=processing&order_id=' . $order->get_id() ), 'woocommerce-mark-order-status' ),
'name' => __( 'Approved', 'woocommerce' ),
'title' => __( 'Change order status to approved', 'woocommerce' ),
'action' => 'processing',
);
}
if ( $order->has_status( array( 'pending', 'on-hold', 'processing' ) ) ) {
$status_actions['complete'] = array(
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=completed&order_id=' . $order->get_id() ), 'woocommerce-mark-order-status' ),
'name' => __( 'Completed', 'woocommerce' ),
'title' => __( 'Change order status to completed', 'woocommerce' ),
'action' => 'complete',
);
}
if ( $status_actions ) {
$actions['status'] = array(
'group' => __( 'Change status: ', 'woocommerce' ),
'actions' => $status_actions,
);
}
return $actions;
}
并在悬停时重命名管理员订单列表按钮上的状态:
add_filter( 'woocommerce_admin_order_actions', 'rename_admin_order_status_action_button', 10, 2 );
function rename_admin_order_status_action_button( $actions, $order ) {
// Display the button for all orders that have a 'processing', 'pending' or 'on-hold' status
if ( isset($actions['processing']) ) {
$actions['processing']['name'] = __( 'Approved', 'woocommerce');
}
return $actions;
}
代码进入您的活动子主题(或活动主题)的 function.php 文件。已测试并有效。
我需要在每个实例中将 "On Hold" 重命名为 "Pending Approval",将 "Processing" 重命名为 "Approved"。 (顺便说一句,我是 diy 店老板,不是开发商)
这个主题让我达到了 60%,
- admin > orders,预览弹出窗口(眼睛符号)。
- 前端 > my-account/orders,状态栏。
- 前端 > my-account/view-order/x,总结行。
我的代码:
add_filter( 'wc_order_statuses', 'rename_order_statuses', 20, 1 );
function rename_order_statuses( $order_statuses ) {
$order_statuses['wc-processing'] = _x( 'Approved', 'Order status', 'woocommerce' );
$order_statuses['wc-on-hold'] = _x( 'Pending Approval', 'Order status', 'woocommerce' );
return $order_statuses;
}
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 Approved', 'woocommerce' );
$actions['mark_on-hold'] = __( 'Mark Pending Approval', 'woocommerce' );
return $actions;
}
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-processing'] ) )
$views['wc-processing'] = str_replace( 'Processing', __( 'Approved', 'woocommerce'), $views['wc-processing'] );
if( isset( $views['wc-on-hold'] ) )
$views['wc-on-hold'] = str_replace( 'On hold', __( 'Pending Approval', 'woocommerce'), $views['wc-on-hold'] );
return $views;
}
你的代码由
前端>my-account/orders,状态栏
前端>my-account/view-order/x,总结行
Otherwise, if it doesn't work, it could be caused by other customizations from you theme, a plugin or your own customizations.
现在要处理 Admin > 订单,预览弹出窗口(眼睛符号) 使用以下代码:
add_filter( 'woocommerce_admin_order_preview_actions', 'filter_admin_order_preview_actions', 10, 2 );
function filter_admin_order_preview_actions( $actions, $order ) {
$actions = array();
$status_actions = array();
if ( $order->has_status( array( 'pending' ) ) ) {
$status_actions['on-hold'] = array(
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=on-hold&order_id=' . $order->get_id() ), 'woocommerce-mark-order-status' ),
'name' => __( 'On-hold', 'woocommerce' ),
'title' => __( 'Change order status to on-hold', 'woocommerce' ),
'action' => 'on-hold',
);
}
if ( $order->has_status( array( 'pending', 'on-hold' ) ) ) {
$status_actions['processing'] = array(
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=processing&order_id=' . $order->get_id() ), 'woocommerce-mark-order-status' ),
'name' => __( 'Approved', 'woocommerce' ),
'title' => __( 'Change order status to approved', 'woocommerce' ),
'action' => 'processing',
);
}
if ( $order->has_status( array( 'pending', 'on-hold', 'processing' ) ) ) {
$status_actions['complete'] = array(
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=completed&order_id=' . $order->get_id() ), 'woocommerce-mark-order-status' ),
'name' => __( 'Completed', 'woocommerce' ),
'title' => __( 'Change order status to completed', 'woocommerce' ),
'action' => 'complete',
);
}
if ( $status_actions ) {
$actions['status'] = array(
'group' => __( 'Change status: ', 'woocommerce' ),
'actions' => $status_actions,
);
}
return $actions;
}
并在悬停时重命名管理员订单列表按钮上的状态:
add_filter( 'woocommerce_admin_order_actions', 'rename_admin_order_status_action_button', 10, 2 );
function rename_admin_order_status_action_button( $actions, $order ) {
// Display the button for all orders that have a 'processing', 'pending' or 'on-hold' status
if ( isset($actions['processing']) ) {
$actions['processing']['name'] = __( 'Approved', 'woocommerce');
}
return $actions;
}
代码进入您的活动子主题(或活动主题)的 function.php 文件。已测试并有效。