Fix bug where active payment methods were checked too early

This commit is contained in:
Alex Florisca 2022-09-01 11:08:42 +01:00
parent dfe5151f7f
commit 080cdbeac2
2 changed files with 7 additions and 0 deletions

View File

@ -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 );
} );

View File

@ -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();