Skip to content

Commit c6de842

Browse files
authored
Do not load ECE button if total amount is 0 (#3553)
* hide ece button if total amount is 0 * update comment * add changelog * check for cart and checkout page * fix condition for pay for order page
1 parent 499a251 commit c6de842

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* Tweak - Add error logging in ECE critical Ajax requests.
1717
* Add - Add support for Stripe Link payments via the new Stripe Checkout Element on the block cart and block checkout pages.
1818
* Add - Add support for Stripe Link payments via the new Stripe Checkout Element on the product, cart, checkout and pay for order pages.
19+
* Tweak - Do not load ECE button if the total amount is 0.
1920
* Add - Show ECE button preview on settings page.
2021
* Tweak - Remove the subscription order notes added each time a source wasn't migrated.
2122

client/blocks/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { getSetting } from '@woocommerce/settings';
1+
/* global wc */
22

33
export const getBlocksConfiguration = () => {
4-
const stripeServerData = getSetting( 'stripe_data', null );
4+
const stripeServerData = wc?.wcSettings?.getSetting( 'stripe_data', null );
55

66
if ( ! stripeServerData ) {
77
throw new Error( 'Stripe initialization data is not available' );

includes/payment-methods/class-wc-stripe-express-checkout-helper.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,14 @@ public function should_show_express_checkout_button() {
571571
return false;
572572
}
573573

574+
// Don't show if the total price is 0.
575+
// ToDo: support free trials. Free trials should be supported if the product does not require shipping.
576+
if ( ( ! ( $this->is_pay_for_order_page() || $this->is_product() ) && 0.0 === (float) WC()->cart->get_total( false ) )
577+
|| ( $this->is_product() && 0.0 === (float) $this->get_product()->get_price() )
578+
) {
579+
return false;
580+
}
581+
574582
if ( $this->is_product() && in_array( $this->get_product()->get_type(), [ 'variable', 'variable-subscription' ], true ) ) {
575583
$stock_availability = array_column( $this->get_product()->get_available_variations(), 'is_in_stock' );
576584
// Don't show if all product variations are out-of-stock.

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
126126
* Tweak - Add error logging in ECE critical Ajax requests.
127127
* Add - Add support for Stripe Link payments via the new Stripe Checkout Element on the block cart and block checkout pages.
128128
* Add - Add support for Stripe Link payments via the new Stripe Checkout Element on the product, cart, checkout and pay for order pages.
129+
* Tweak - Do not load ECE button if the total amount is 0.
129130
* Add - Show ECE button preview on settings page.
130131
* Tweak - Remove the subscription order notes added each time a source wasn't migrated.
131132

0 commit comments

Comments
 (0)