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.
This commit is contained in:
Thomas Roberts 2021-10-14 10:37:29 +01:00
parent b905b9208f
commit d3421126e7
No known key found for this signature in database
GPG Key ID: 7C7EC4402EC08F35
1 changed files with 12 additions and 1 deletions

View File

@ -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;
}