Skip to content

Commit

Permalink
Refactor isRequired assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmx-dev committed Nov 13, 2024
1 parent a61119f commit 3955748
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions client/checkout/classic/event-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3955748

Please sign in to comment.