From 939d429389c5a4d07627149d8099be72cb7e813b Mon Sep 17 00:00:00 2001 From: Josh Betz Date: Wed, 23 Mar 2022 11:09:50 -0500 Subject: [PATCH] Simplify product variation filtering Fixes an issue where we were conditionally mutating the meta key and value. This was originally copy/pasted from somewhere else. In this context, we don't need all of these values, so the simpler approach is good. Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com> --- .../Version2/class-wc-rest-orders-v2-controller.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php b/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php index ebbaa118c0e..421a55e0c11 100644 --- a/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php +++ b/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php @@ -217,11 +217,7 @@ class WC_REST_Orders_V2_Controller extends WC_REST_CRUD_Controller { $data['meta_data'] = array_filter( $data['meta_data'], function( $meta ) use ( $product, $order_item_name ) { - $meta->key = rawurldecode( (string) $meta->key ); - $meta->value = rawurldecode( (string) $meta->value ); - $attribute_key = str_replace( 'attribute_', '', $meta->key ); - $display_key = wc_attribute_label( $attribute_key, $product ); - $display_value = wp_kses_post( $meta->value ); + $display_value = wp_kses_post( rawurldecode( (string) $meta->value ) ); // Skip items with values already in the product details area of the product name. if ( $product && $product->is_type( 'variation' ) && wc_is_attribute_in_product_name( $display_value, $order_item_name ) ) {