Skip to content

Commit 68380da

Browse files
authored
ECE on shortcode cart page (#3490)
* show button before 'proceed to checkout' * add gap below the ece button * add separator on cart page * refresh ece button when total amount is updated * changelog entry * fix condition
1 parent a0c1387 commit 68380da

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

changelog.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
* Fix - Updates the display logic for the OAuth re-connect promotional surface to follow the latest changes made to the connection settings object.
99
* Fix - Remove unexpected HTML in error message for shortcode checkout.
1010
* Fix - Ensure ordering for Stripe payment methods is saved even when setting up from scratch.
11-
* Add - Add support for Stripe Express Checkout Element on the block cart and checkout page.
1211
* Add - Implemented the "Update all subscriptions payment methods" checkbox on My Account → Payment methods for UPE payment methods.
13-
* Add - Add support for the new Stripe Checkout Element on the shortcode checkout page.
14-
* Add - Add support for the new Stripe Checkout Element on the pay for order page.
12+
* Add - Add support for the new Stripe Express Checkout Element on the block cart and checkout page.
13+
* Add - Add support for the new Stripe Express Checkout Element on the shortcode checkout page.
14+
* Add - Add support for the new Stripe Express Checkout Element on the shortcode cart page.
15+
* Add - Add support for the new Stripe Express Checkout Element on the pay for order page.
1516
* Add - Add support for the new Stripe Checkout Element on the product page.
1617
* Dev - Introduces a new class with payment methods constants.
1718
* Dev - Introduces a new class with currency codes constants.

client/entrypoints/express-checkout/index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,20 @@ jQuery( function ( $ ) {
618618
},
619619
};
620620

621-
wcStripeECE.init();
621+
// We don't need to initialize ECE on the checkout page now because it will be initialized by updated_checkout event.
622+
if ( ! getExpressCheckoutData( 'is_checkout_page' ) ) {
623+
wcStripeECE.init();
624+
}
625+
626+
// We need to refresh ECE data when total is updated.
627+
$( document.body ).on( 'updated_cart_totals', () => {
628+
wcStripeECE.init();
629+
} );
630+
631+
// We need to refresh ECE data when total is updated.
632+
$( document.body ).on( 'updated_checkout', () => {
633+
wcStripeECE.init();
634+
} );
622635

623636
// Handle bookable products on the product page.
624637
let wcBookingFormChanged = false;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
#wc-stripe-express-checkout-element iframe {
22
max-width: unset;
33
}
4+
5+
#wc-stripe-express-checkout-element {
6+
margin-bottom: 12px;
7+
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function init() {
9191
add_action( 'wp_enqueue_scripts', [ $this, 'scripts' ] );
9292

9393
add_action( 'woocommerce_after_add_to_cart_form', [ $this, 'display_express_checkout_button_html' ], 1 );
94-
add_action( 'woocommerce_proceed_to_checkout', [ $this, 'display_express_checkout_button_html' ], 25 );
94+
add_action( 'woocommerce_proceed_to_checkout', [ $this, 'display_express_checkout_button_html' ] );
9595
add_action( 'woocommerce_checkout_before_customer_details', [ $this, 'display_express_checkout_button_html' ], 1 );
9696
add_action( 'woocommerce_pay_order_before_payment', [ $this, 'display_express_checkout_button_html' ], 1 );
9797

@@ -413,14 +413,18 @@ public function display_express_checkout_button_html() {
413413
* Display express checkout button separator.
414414
*/
415415
public function display_express_checkout_button_separator_html() {
416-
if ( ! is_checkout() && ! is_wc_endpoint_url( 'order-pay' ) ) {
416+
if ( ! is_checkout() && ! is_cart() && ! is_wc_endpoint_url( 'order-pay' ) ) {
417417
return;
418418
}
419419

420420
if ( is_checkout() && ! in_array( 'checkout', $this->express_checkout_helper->get_button_locations(), true ) ) {
421421
return;
422422
}
423423

424+
if ( is_cart() && ! in_array( 'cart', $this->express_checkout_helper->get_button_locations(), true ) ) {
425+
return;
426+
}
427+
424428
?>
425429
<p id="wc-stripe-express-checkout-button-separator" style="margin-top:1.5em;text-align:center;display:none;">&mdash; <?php esc_html_e( 'OR', 'woocommerce-gateway-stripe' ); ?> &mdash;</p>
426430
<?php

readme.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,11 @@ If you get stuck, you can ask for help in the Plugin Forum.
136136
* Fix - Updates the display logic for the OAuth re-connect promotional surface to follow the latest changes made to the connection settings object.
137137
* Fix - Remove unexpected HTML in error message for shortcode checkout.
138138
* Fix - Ensure ordering for Stripe payment methods is saved even when setting up from scratch.
139-
* Add - Add support for Stripe Express Checkout Element on the block cart and checkout page.
140139
* Add - Implemented the "Update all subscriptions payment methods" checkbox on My Account → Payment methods for UPE payment methods.
141-
* Add - Add support for the new Stripe Checkout Element on the shortcode checkout page.
142-
* Add - Add support for the new Stripe Checkout Element on the pay for order page.
140+
* Add - Add support for the new Stripe Express Checkout Element on the block cart and checkout page.
141+
* Add - Add support for the new Stripe Express Checkout Element on the shortcode checkout page.
142+
* Add - Add support for the new Stripe Express Checkout Element on the shortcode cart page.
143+
* Add - Add support for the new Stripe Express Checkout Element on the pay for order page.
143144
* Add - Add support for the new Stripe Checkout Element on the product page.
144145
* Dev - Introduces a new class with payment methods constants.
145146
* Dev - Introduces a new class with currency codes constants.

0 commit comments

Comments
 (0)