diff --git a/includes/class-wc-form-handler.php b/includes/class-wc-form-handler.php index 08948932c01..bed912ad14e 100644 --- a/includes/class-wc-form-handler.php +++ b/includes/class-wc-form-handler.php @@ -855,13 +855,7 @@ class WC_Form_Handler { // If no variation ID is set, attempt to get a variation ID from posted attributes. if ( empty( $variation_id ) ) { $data_store = WC_Data_Store::load( 'product' ); - $variation_id = $data_store->find_matching_product_variation( $adding_to_cart, wp_unslash( $_POST ) ); - } - - // If no variation ID is set, attempt to get a variation ID from posted attributes. - if ( empty( $variation_id ) ) { - $data_store = WC_Data_Store::load( 'product' ); - $variation_id = $data_store->find_matching_product_variation( $adding_to_cart, wp_unslash( $_POST ) ); + $variation_id = $data_store->find_matching_product_variation( $adding_to_cart, array_map( 'sanitize_title', wp_unslash( $_REQUEST ) ) ); } // Validate the attributes.