Skip to content

Commit

Permalink
Check if condition is set before setting a default value.
Browse files Browse the repository at this point in the history
  • Loading branch information
rawdreeg committed Mar 14, 2024
1 parent c6c4059 commit aba84fe
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions includes/fbutils.php
Original file line number Diff line number Diff line change
Expand Up @@ -729,8 +729,14 @@ public static function get_cached_best_tip() {
* @return array
*/
public static function normalize_product_data_for_items_batch( $data ) {
// Allowed values are 'refurbished', 'used', and 'new', but the plugin has always used the latter.
$data['condition'] = 'new';
/*
* To avoid overriding the condition value, we check if the value is set or is not one of
* the allowed values before setting it to 'new'. Allowed values are 'refurbished', 'used', and 'new'.
*/
if ( ! isset( $data['condition'] ) || ! in_array( $data['condition'], [ 'refurbished', 'used', 'new' ], true ) ) {
$data['condition'] = 'new';
}

// Attributes other than size, color, pattern, or gender need to be included in the additional_variant_attributes field.
if ( isset( $data['custom_data'] ) && is_array( $data['custom_data'] ) ) {
$attributes = [];
Expand Down

0 comments on commit aba84fe

Please sign in to comment.