diff --git a/plugins/woocommerce/includes/admin/list-tables/class-wc-admin-list-table-orders.php b/plugins/woocommerce/includes/admin/list-tables/class-wc-admin-list-table-orders.php index 6c604088976..81d7c1850c1 100644 --- a/plugins/woocommerce/includes/admin/list-tables/class-wc-admin-list-table-orders.php +++ b/plugins/woocommerce/includes/admin/list-tables/class-wc-admin-list-table-orders.php @@ -507,7 +507,10 @@ class WC_Admin_List_Table_Orders extends WC_Admin_List_Table { $html .= '
' . esc_html( $product_object->get_sku() ) . '
'; } - $meta_data = $item->get_formatted_meta_data( '' ); + + $include_all = false; + $include_all = apply_filters( 'woocommerce_get_formatted_meta_data_include_all_meta_lines', $include_all, $item ); + $meta_data = $item->get_formatted_meta_data( '', $include_all ); if ( $meta_data ) { $html .= ''; diff --git a/plugins/woocommerce/includes/class-wc-order-item.php b/plugins/woocommerce/includes/class-wc-order-item.php index 2445328a253..a65b1baf0cf 100644 --- a/plugins/woocommerce/includes/class-wc-order-item.php +++ b/plugins/woocommerce/includes/class-wc-order-item.php @@ -279,19 +279,8 @@ class WC_Order_Item extends WC_Data implements ArrayAccess { } } - $show_metadata_line = ! $include_all && - $product && $product->is_type( 'variation' ) && - wc_is_attribute_in_product_name( $display_value, $order_item_name ); - $show_metadata_line = apply_filters( - 'woocommerce_show_product_variant_metadata_line', - $attribute_key, - $display_value, - $product, - $show_metadata_line - ); - // Skip items with values already in the product details area of the product name. - if ( ! $show_metadata_line ) { + if ( ! $include_all && $product && $product->is_type( 'variation' ) && wc_is_attribute_in_product_name( $display_value, $order_item_name ) ) { continue; } diff --git a/plugins/woocommerce/includes/legacy/api/v2/class-wc-api-orders.php b/plugins/woocommerce/includes/legacy/api/v2/class-wc-api-orders.php index cfc2d13c95b..1e8fbd5ff7c 100644 --- a/plugins/woocommerce/includes/legacy/api/v2/class-wc-api-orders.php +++ b/plugins/woocommerce/includes/legacy/api/v2/class-wc-api-orders.php @@ -213,7 +213,10 @@ class WC_API_Orders extends WC_API_Resource { foreach ( $order->get_items() as $item_id => $item ) { $product = $item->get_product(); $hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_'; - $item_meta = $item->get_formatted_meta_data( $hideprefix ); + + $include_all = false; + $include_all = apply_filters( 'woocommerce_get_formatted_meta_data_include_all_meta_lines', $include_all, $item ); + $item_meta = $item->get_formatted_meta_data( $hideprefix, $include_all ); foreach ( $item_meta as $key => $values ) { $item_meta[ $key ]->label = $values->display_key; @@ -1525,7 +1528,10 @@ class WC_API_Orders extends WC_API_Resource { foreach ( $refund->get_items( 'line_item' ) as $item_id => $item ) { $product = $item->get_product(); $hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_'; - $item_meta = $item->get_formatted_meta_data( $hideprefix ); + + $include_all = false; + $include_all = apply_filters( 'woocommerce_get_formatted_meta_data_include_all_meta_lines', $include_all, $item ); + $item_meta = $item->get_formatted_meta_data( $hideprefix, $include_all ); foreach ( $item_meta as $key => $values ) { $item_meta[ $key ]->label = $values->display_key; diff --git a/plugins/woocommerce/includes/legacy/api/v3/class-wc-api-orders.php b/plugins/woocommerce/includes/legacy/api/v3/class-wc-api-orders.php index 2fe2b6cdcf4..18ceabc529f 100644 --- a/plugins/woocommerce/includes/legacy/api/v3/class-wc-api-orders.php +++ b/plugins/woocommerce/includes/legacy/api/v3/class-wc-api-orders.php @@ -220,7 +220,10 @@ class WC_API_Orders extends WC_API_Resource { foreach ( $order->get_items() as $item_id => $item ) { $product = $item->get_product(); $hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_'; - $item_meta = $item->get_formatted_meta_data( $hideprefix ); + + $include_all = false; + $include_all = apply_filters( 'woocommerce_get_formatted_meta_data_include_all_meta_lines', $include_all, $item ); + $item_meta = $item->get_formatted_meta_data( $hideprefix, $include_all ); foreach ( $item_meta as $key => $values ) { $item_meta[ $key ]->label = $values->display_key; @@ -1570,7 +1573,10 @@ class WC_API_Orders extends WC_API_Resource { foreach ( $refund->get_items( 'line_item' ) as $item_id => $item ) { $product = $item->get_product(); $hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_'; - $item_meta = $item->get_formatted_meta_data( $hideprefix ); + + $include_all = false; + $include_all = apply_filters( 'woocommerce_get_formatted_meta_data_include_all_meta_lines', $include_all, $item ); + $item_meta = $item->get_formatted_meta_data( $hideprefix, $include_all ); foreach ( $item_meta as $key => $values ) { $item_meta[ $key ]->label = $values->display_key; diff --git a/plugins/woocommerce/includes/wc-template-functions.php b/plugins/woocommerce/includes/wc-template-functions.php index bbf1a556f42..436abcccfc5 100644 --- a/plugins/woocommerce/includes/wc-template-functions.php +++ b/plugins/woocommerce/includes/wc-template-functions.php @@ -3336,7 +3336,9 @@ if ( ! function_exists( 'wc_display_item_meta' ) ) { ) ); - foreach ( $item->get_formatted_meta_data() as $meta_id => $meta ) { + $include_all = false; + $include_all = apply_filters( 'woocommerce_get_formatted_meta_data_include_all_meta_lines', $include_all, $item ); + foreach ( $item->get_formatted_meta_data( '_', $include_all ) as $meta_id => $meta ) { $value = $args['autop'] ? wp_kses_post( $meta->display_value ) : wp_kses_post( make_clickable( trim( $meta->display_value ) ) ); $strings[] = $args['label_before'] . wp_kses_post( $meta->display_key ) . $args['label_after'] . $value; }