Skip to content

Commit b4d593f

Browse files
authored
Fix undefined element error on Cart block for WooPay enabled site. (#5159)
1 parent 1bfffe1 commit b4d593f

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fix
3+
4+
Fix undefined element error on Cart block for WooPay enabled site.

client/checkout/blocks/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ registerPaymentMethod( {
5252

5353
registerExpressPaymentMethod( paymentRequestPaymentMethod( api ) );
5454

55-
if ( getConfig( 'isPlatformCheckoutEnabled' ) ) {
55+
// If platform checkout is enabled and this is the checkout page.
56+
if (
57+
getConfig( 'isPlatformCheckoutEnabled' ) &&
58+
document.querySelector( '[data-block-name="woocommerce/checkout"]' )
59+
) {
5660
handlePlatformCheckoutEmailInput( '#email', api, true );
5761
}
5862

client/checkout/platform-checkout/email-input-iframe.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ const waitForElement = ( selector ) => {
1818
const checkoutBlock = document.querySelector(
1919
'[data-block-name="woocommerce/checkout"]'
2020
);
21+
22+
if ( ! checkoutBlock ) {
23+
return resolve( null );
24+
}
25+
2126
const observer = new MutationObserver( ( mutationList, obs ) => {
2227
if ( document.querySelector( selector ) ) {
2328
resolve( document.querySelector( selector ) );

0 commit comments

Comments
 (0)