[2.2] When formatting meta data for display, suffix items to prevent issues when there are multiple values for the same meta key

Fixes #6404
This commit is contained in:
Mike Jolley 2014-10-06 12:17:07 +01:00
parent 7d9598d0a8
commit 90297a09af
1 changed files with 9 additions and 1 deletions

View File

@ -139,7 +139,15 @@ class WC_Order_Item_Meta {
}
}
$formatted_meta[ $meta_key ] = array(
// Unique key required
$formatted_meta_key = $meta_key;
$loop = 0;
while ( isset( $formatted_meta[ $formatted_meta_key ] ) ) {
$loop ++;
$formatted_meta_key = $meta_key . '-' . $loop;
}
$formatted_meta[ $formatted_meta_key ] = array(
'label' => wc_attribute_label( $attribute_key ),
'value' => apply_filters( 'woocommerce_order_item_display_meta_value', $meta_value ),
);