Skip to content

Commit 1c07c36

Browse files
remove not needed method
1 parent 001547f commit 1c07c36

File tree

2 files changed

+1
-52
lines changed

2 files changed

+1
-52
lines changed

src/js/_utils.js

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -121,50 +121,3 @@ export const getCheckOutFieldsLabel = ( field, billingOrShipping ) => {
121121
export const amazonPayCanMakePayment = ( { cartTotals }, { allowedCurrencies } ) => {
122122
return allowedCurrencies && allowedCurrencies.length > 0 ? allowedCurrencies.includes( cartTotals.currency_code ) : true;
123123
};
124-
125-
126-
/**
127-
* Maybe override required field validation.
128-
*
129-
* @param {string} country The country code.
130-
* @returns {array}
131-
*/
132-
export const overrideRequiredFieldValidation = ( country ) => {
133-
let overridenFields = [];
134-
135-
if ( ! window.amazon_payments_advanced ||
136-
! window.amazon_payments_advanced.overriden_fields_per_country ||
137-
! window.amazon_payments_advanced.overriden_fields_per_country[ country ]
138-
) {
139-
return overridenFields;
140-
}
141-
142-
const fieldsToOverride = window.amazon_payments_advanced.overriden_fields_per_country[ country ];
143-
144-
for ( const field of fieldsToOverride ) {
145-
const elem = document.getElementById( field );
146-
if ( ! elem || ! elem.required ) {
147-
continue;
148-
}
149-
150-
elem.required = false;
151-
overridenFields.push( field );
152-
}
153-
154-
return overridenFields;
155-
}
156-
157-
158-
/**
159-
* Restore the required field validation.
160-
*
161-
* @param {array} fields The fields to restore the required validation.
162-
*/
163-
export const restoreRequiredFieldValidation = ( fields ) => {
164-
fields.forEach( field => {
165-
const elem = document.getElementById( field );
166-
if ( elem ) {
167-
elem.required = true;
168-
}
169-
} );
170-
}

src/js/payments-methods/express/_payment-methods.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import React from 'react';
99
/**
1010
* Internal dependencies
1111
*/
12-
import { getCheckOutFieldsLabel, overrideRequiredFieldValidation, restoreRequiredFieldValidation } from '../../_utils';
12+
import { getCheckOutFieldsLabel } from '../../_utils';
1313
import { activateChange } from '../../_renderAmazonButton';
1414
import { settings } from './_settings';
1515

@@ -44,13 +44,9 @@ const AmazonPayInfo = ( props ) => {
4444

4545
const { amazonBilling, amazonShipping } = settings.amazonAddress;
4646

47-
const [ overridenFields, setOverridenFields ] = useState( [] );
48-
4947
useEffect( () => {
5048
const unsubscribe = props.eventRegistration.onCheckoutValidation(
5149
async () => {
52-
restoreRequiredFieldValidation( overridenFields );
53-
setOverridenFields( overrideRequiredFieldValidation( shippingAddress?.country || '' ) );
5450
for ( const shippingField in amazonShipping ) {
5551
// Values are the same as expected. Bail.
5652
if (amazonShipping[ shippingField ] === shippingAddress[ shippingField ]) {

0 commit comments

Comments
 (0)