From d3421126e754b8060ee5cd4377fffe8789e892ee Mon Sep 17 00:00:00 2001 From: Thomas Roberts Date: Thu, 14 Oct 2021 10:37:29 +0100 Subject: [PATCH] Add 'woocommerce_show_product_variant_metadata_line' hook This can be used to allow extensions to override whether the metadata line is displayed in the order meta box or not. --- .../woocommerce/includes/class-wc-order-item.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce/includes/class-wc-order-item.php b/plugins/woocommerce/includes/class-wc-order-item.php index a65b1baf0cf..2445328a253 100644 --- a/plugins/woocommerce/includes/class-wc-order-item.php +++ b/plugins/woocommerce/includes/class-wc-order-item.php @@ -279,8 +279,19 @@ 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 ( ! $include_all && $product && $product->is_type( 'variation' ) && wc_is_attribute_in_product_name( $display_value, $order_item_name ) ) { + if ( ! $show_metadata_line ) { continue; }