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>
This commit is contained in:
Josh Betz 2022-03-23 11:09:50 -05:00 committed by GitHub
parent 31bcda40b2
commit 939d429389
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 5 deletions

View File

@ -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 ) ) {