Skip to content

Commit 6d320ae

Browse files
annemirasoldiegocurbelo
authored andcommitted
Exclude Pay for Order page from logic hiding ECE when taxes may be inaccurate (#3601)
* Exclude Pay for Order page from ECE tax logic * Add unit test
1 parent 127f0a1 commit 6d320ae

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ public function should_show_express_checkout_button() {
600600

601601
// Hide if cart/product doesn't require shipping and tax is based on billing or shipping address.
602602
if (
603+
! $this->is_pay_for_order_page() &&
603604
(
604605
( is_product() && ! $this->product_needs_shipping( $this->get_product() ) ) ||
605606
( ( is_cart() || is_checkout() ) && ! WC()->cart->needs_shipping() )

tests/phpunit/test-wc-stripe-express-checkout-helper.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,14 @@ public function test_hides_ece_if_cannot_compute_taxes() {
6060
'allowed_items_in_cart',
6161
'should_show_ece_on_cart_page',
6262
'should_show_ece_on_checkout_page',
63+
'is_pay_for_order_page',
6364
]
6465
);
6566
$wc_stripe_ece_helper_mock->expects( $this->any() )->method( 'is_product' )->willReturn( false );
6667
$wc_stripe_ece_helper_mock->expects( $this->any() )->method( 'allowed_items_in_cart' )->willReturn( true );
6768
$wc_stripe_ece_helper_mock->expects( $this->any() )->method( 'should_show_ece_on_cart_page' )->willReturn( true );
6869
$wc_stripe_ece_helper_mock->expects( $this->any() )->method( 'should_show_ece_on_checkout_page' )->willReturn( true );
70+
$wc_stripe_ece_helper_mock->expects( $this->any() )->method( 'is_pay_for_order_page' )->willReturnOnConsecutiveCalls( true, false );
6971
$wc_stripe_ece_helper_mock->testmode = true;
7072
if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) {
7173
define( 'WOOCOMMERCE_CHECKOUT', true );
@@ -83,6 +85,10 @@ public function test_hides_ece_if_cannot_compute_taxes() {
8385
WC()->session->init();
8486
WC()->cart->add_to_cart( $virtual_product->get_id(), 1 );
8587

88+
// Do not hide if Pay for Order page.
89+
update_option( 'woocommerce_tax_based_on', 'shipping' );
90+
$this->assertTrue( $wc_stripe_ece_helper_mock->should_show_express_checkout_button() );
91+
8692
// Hide if cart has virtual product and tax is based on shipping or billing address.
8793
update_option( 'woocommerce_calc_taxes', 'yes' );
8894
update_option( 'woocommerce_tax_based_on', 'billing' );

0 commit comments

Comments
 (0)