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

Commit

Permalink
Fix bug where active payment methods were checked too early
Browse files Browse the repository at this point in the history
  • Loading branch information
alexflorisca committed Sep 1, 2022
1 parent b253a6d commit 58b791e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions assets/js/data/cart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ const registeredStore = registerStore< State >( STORE_KEY, {

registeredStore.subscribe( pushChanges );
registeredStore.subscribe( async () => {
const isInitialized =
wpDataSelect( STORE_KEY ).hasFinishedResolution( 'getCartData' );

if ( ! isInitialized ) {
return;
}
await checkPaymentMethodsCanPay();
await checkPaymentMethodsCanPay( true );
} );
Expand Down
1 change: 1 addition & 0 deletions assets/js/data/checkout/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ register( store );

const isEditor = !! wpDataSelect( 'core/editor' );

// This is needed to ensure that the payment methods are displayed in the editor
if ( isEditor ) {
subscribe( async () => {
await checkPaymentMethodsCanPay();
Expand Down

0 comments on commit 58b791e

Please sign in to comment.