From fe976b4ec9cb62b326246bf963297c9191ced096 Mon Sep 17 00:00:00 2001 From: Anne Mirasol Date: Thu, 17 Oct 2024 16:53:01 -0500 Subject: [PATCH 1/2] Hide Express Checkout in block editor if disabled --- client/blocks/upe/index.js | 8 ++++++-- includes/class-wc-stripe-blocks-support.php | 22 +++++++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/client/blocks/upe/index.js b/client/blocks/upe/index.js index 189fed2ca..2f8726a7c 100644 --- a/client/blocks/upe/index.js +++ b/client/blocks/upe/index.js @@ -94,12 +94,16 @@ Object.entries( paymentMethodsConfig ) } ); } ); -if ( getBlocksConfiguration()?.isECEEnabled ) { +const blocksConfig = getBlocksConfiguration(); +if ( + blocksConfig?.isECEEnabled && + blocksConfig?.shouldShowExpressCheckoutButton +) { // Register Express Checkout Element. registerExpressPaymentMethod( expressCheckoutElementsGooglePay( api ) ); registerExpressPaymentMethod( expressCheckoutElementsApplePay( api ) ); registerExpressPaymentMethod( expressCheckoutElementsStripeLink( api ) ); -} else { +} else if ( blocksConfig?.shouldShowPaymentRequestButton ) { // Register Stripe Payment Request. registerExpressPaymentMethod( paymentRequestPaymentMethod ); } diff --git a/includes/class-wc-stripe-blocks-support.php b/includes/class-wc-stripe-blocks-support.php index fa93dcdda..0fd0a49bb 100644 --- a/includes/class-wc-stripe-blocks-support.php +++ b/includes/class-wc-stripe-blocks-support.php @@ -188,13 +188,14 @@ public function get_payment_method_data() { $js_params, // Blocks-specific options [ - 'icons' => $this->get_icons(), - 'supports' => $this->get_supported_features(), - 'showSavedCards' => $this->get_show_saved_cards(), - 'showSaveOption' => $this->get_show_save_option(), - 'isAdmin' => is_admin(), - 'shouldShowPaymentRequestButton' => $this->should_show_payment_request_button(), - 'button' => [ + 'icons' => $this->get_icons(), + 'supports' => $this->get_supported_features(), + 'showSavedCards' => $this->get_show_saved_cards(), + 'showSaveOption' => $this->get_show_save_option(), + 'isAdmin' => is_admin(), + 'shouldShowPaymentRequestButton' => $this->should_show_payment_request_button(), + 'shouldShowExpressCheckoutButton' => $this->should_show_express_checkout_button(), + 'button' => [ 'customLabel' => $this->payment_request_configuration->get_button_label(), ], ] @@ -255,10 +256,15 @@ private function should_show_payment_request_button() { * @return boolean True if ECEs should be displayed, false otherwise. */ private function should_show_express_checkout_button() { + // Don't show if ECEs are turned off in settings. + if ( ! $this->express_checkout_configuration->express_checkout_helper->is_express_checkout_enabled() ) { + return false; + } + // Don't show if ECEs are supposed to be hidden on the cart page. if ( has_block( 'woocommerce/cart' ) - && ! $this->express_checkout_configuration->express_checkout_helper->should_show_ece_on_cart_page()() + && ! $this->express_checkout_configuration->express_checkout_helper->should_show_ece_on_cart_page() ) { return false; } From 19cd1cab9072e91682fe08929aff5803a4f32e25 Mon Sep 17 00:00:00 2001 From: Anne Mirasol Date: Fri, 18 Oct 2024 17:10:23 -0500 Subject: [PATCH 2/2] Add changelog and readme entries --- changelog.txt | 1 + readme.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/changelog.txt b/changelog.txt index ce855a7c1..befbe40cf 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,7 @@ = 8.9.0 - xxxx-xx-xx = * Tweak - Makes the new Stripe Express Checkout Element enabled by default. * Dev - Add multiple unit tests for the Stripe Express Checkout Element implementation (for both frontend and backend). +* Fix - Do not show Express Payment block in block editor if it's not enabled as a payment method. * Fix - Corrected card brand capitalization on the My Account → Subscription page. * Fix - Displays a specific message when an authentication error occurs during checkout for 3DS cards (shortcode version). * Fix - Show 'Use a New Payment Method' radio button for logged in users only when card saving is enabled. diff --git a/readme.txt b/readme.txt index b3c509475..4dd6283e7 100644 --- a/readme.txt +++ b/readme.txt @@ -113,6 +113,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o = 8.9.0 - xxxx-xx-xx = * Tweak - Makes the new Stripe Express Checkout Element enabled by default. * Dev - Add multiple unit tests for the Stripe Express Checkout Element implementation (for both frontend and backend). +* Fix - Do not show Express Payment block in block editor if it's not enabled as a payment method. * Fix - Corrected card brand capitalization on the My Account → Subscription page. * Fix - Displays a specific message when an authentication error occurs during checkout for 3DS cards (shortcode version). * Fix - Show 'Use a New Payment Method' radio button for logged in users only when card saving is enabled.