问题
Following Display a product custom field only in WooCommerce Admin single orders answer to my previous question, which:
- Adds a Custom SKU Field (ArticleID)
- Saves the Custom SKU (ArticleID) as Hidden Order Item Meta Data
- Saves the Custom SKU (ArticleID) as Hidden Order Item Meta Data for Manual Orders
How can I change the displayed meta key label _articleid
on order line items section of the admin single order pages?
Right now it shows the "SKU", the "Variation ID" (for product variations) and the "_articleid".
I'd like to replace displayed "_articleid" with "Article ID" instead.
Any help?
回答1:
You will use the following to replace displayed key label _articleid
with for example 'Article ID' in order items on WooCommerce admin single orders:
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). It should works.
Related:
Change order item custom meta data displayed label and value in WooCommerce Admin orders
Related to this thread:
- How to show a product custom field (custom SKU) in WooCommerce orders
- Display a product custom field only in WooCommerce Admin single orders for Manual Orders
来源:https://stackoverflow.com/questions/65893733/change-order-item-displayed-meta-key-label-in-woocommerce-admin-order-pages