简体   繁体   English

WooCommerce 管理订单页面中显示的更改订单项目元键 label

[英]Change order item displayed meta key label in WooCommerce admin order pages

Following Display a product custom field only in WooCommerce Admin single orders answer to my previous question, which:以下仅在 WooCommerce 管理员单个订单中显示产品自定义字段,回答我之前的问题,其中:

  1. Adds a Custom SKU Field (ArticleID)添加自定义 SKU 字段 (ArticleID)
  2. Saves the Custom SKU (ArticleID) as Hidden Order Item Meta Data将自定义 SKU (ArticleID) 保存为隐藏的订单商品元数据
  3. Saves the Custom SKU (ArticleID) as Hidden Order Item Meta Data for Manual Orders将自定义 SKU (ArticleID) 保存为手动订单的隐藏订单商品元数据

How can I change the displayed meta key label _articleid on order line items section of the admin single order pages?如何更改管理单个订单页面的订单行项目部分上显示的元键 label _articleid

Right now it shows the "SKU", the "Variation ID" (for product variations) and the "_articleid".现在它显示“SKU”、“变体 ID”(用于产品变体)和“_articleid”。

I'd like to replace displayed "_articleid" with "Article ID" instead.我想用“文章 ID”替换显示的“_articleid”。

Any help?有什么帮助吗?

You will use the following to replace displayed key label _articleid with for example 'Article ID' in order items on WooCommerce admin single orders:您将使用以下内容将显示的密钥 label _articleid替换为例如 WooCommerce 管理员单一订单上的订单项目中的“文章 ID”:

add_filter('woocommerce_order_item_display_meta_key', 'filter_wc_order_item_display_meta_key', 20, 3 );
function filter_wc_order_item_display_meta_key( $display_key, $meta, $item ) {

    // Change displayed label for specific order item meta key
    if( is_admin() && $item->get_type() === 'line_item' && $meta->key === '_articleid' ) {
        $display_key = __("Article ID", "woocommerce" );
    }
    return $display_key;
}

Code goes in functions.php file of the active child theme (or active theme).代码进入活动子主题(或活动主题)的functions.php文件。 It should works.它应该有效。

Related:有关的:

Change order item custom meta data displayed label and value in WooCommerce Admin orders 更改订单项目自定义元数据显示 label 和 WooCommerce 中的值管理订单

Related to this thread:与此线程相关:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM