From 395574828f4892e0109b3ddd84d3e9d9aa5129bb Mon Sep 17 00:00:00 2001 From: Daniel Guerra Date: Wed, 13 Nov 2024 11:53:28 -0600 Subject: [PATCH] Refactor isRequired assignments --- client/checkout/classic/event-handlers.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/client/checkout/classic/event-handlers.js b/client/checkout/classic/event-handlers.js index b8e8ba46156..0bcfc06f8d1 100644 --- a/client/checkout/classic/event-handlers.js +++ b/client/checkout/classic/event-handlers.js @@ -291,19 +291,13 @@ jQuery( function ( $ ) { return Boolean( billingFieldsToValidate.find( ( fieldName ) => { const $field = document.querySelector( `#${ fieldName }` ); - let isRequired = false; + let isRequired = enabledBillingFields[ fieldName ]?.required; if ( country && locale && fieldName !== 'billing_email' ) { const key = fieldName.replace( 'billing_', '' ); - const fieldSettings = jQuery.extend( - true, - {}, - locale.default[ key ], - locale[ country ][ key ] - ); - isRequired = fieldSettings.required; - } else { - isRequired = enabledBillingFields[ fieldName ]?.required; + isRequired = + locale[ country ][ key ]?.required ?? + locale.default[ key ]?.required; } const hasValue = $field?.value;