Preserve original meta value.

This commit is contained in:
Vedanshu Jain 2023-07-28 14:31:14 +05:30
parent e557241a6b
commit a0a231f804
1 changed files with 2 additions and 4 deletions

View File

@ -716,10 +716,8 @@ abstract class Abstract_WC_Order_Data_Store_CPT extends WC_Data_Store_WP impleme
foreach ( $order->get_meta_data() as $meta_data ) {
if ( isset( $existing_meta_data[ $meta_data->key ] ) ) {
// We don't know if the meta is single or array, so we assume it to be array.
if ( ! is_array( $meta_data->value ) ) {
$meta_data->value = array( $meta_data->value );
}
if ( $existing_meta_data[ $meta_data->key ] === $meta_data->value ) {
$meta_value = is_array( $meta_data->value ) ? $meta_data->value : array( $meta_data->value );
if ( $existing_meta_data[ $meta_data->key ] === $meta_value ) {
unset( $existing_meta_data[ $meta_data->key ] );
continue;
}