Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit d532547

Browse files
authored
Fix:3501 Omit keys in customerPaymentMethods that have an empty list as a value. (#3502)
* Don't add empty methods key.
1 parent 6d872e9 commit d532547

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

assets/js/base/context/cart-checkout/payment-methods/payment-method-data-context.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,16 @@ const getCustomerPaymentMethods = ( availablePaymentMethods = [] ) => {
9393
}
9494
const enabledCustomerPaymentMethods = {};
9595
paymentMethodKeys.forEach( ( type ) => {
96-
enabledCustomerPaymentMethods[ type ] = customerPaymentMethods[
97-
type
98-
].filter( ( paymentMethod ) => {
99-
return Object.keys( availablePaymentMethods ).includes(
100-
paymentMethod.method.gateway
101-
);
102-
} );
96+
const methods = customerPaymentMethods[ type ].filter(
97+
( paymentMethod ) => {
98+
return Object.keys( availablePaymentMethods ).includes(
99+
paymentMethod.method.gateway
100+
);
101+
}
102+
);
103+
if ( methods.length ) {
104+
enabledCustomerPaymentMethods[ type ] = methods;
105+
}
103106
} );
104107
return enabledCustomerPaymentMethods;
105108
};

0 commit comments

Comments
 (0)