Skip to content

Commit 4596314

Browse files
authored
Check if taxes are enabled in ECE tax compatibility logic (#3563)
* Check if taxes are enabled in ECE tax compatibility logic * Update unit tests
1 parent 3db5663 commit 4596314

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
= 8.9.0 - xxxx-xx-xx =
44
* Tweak - Makes the new Stripe Express Checkout Element enabled by default.
55
* Dev - Add multiple unit tests for the Stripe Express Checkout Element implementation (for both frontend and backend).
6+
* Fix - Check if taxes are enabled when applying ECE tax compatibility check.
67
* Fix - Fix ECE error when initial address on load is not defined as a shipping zone.
78
* Fix - Corrected card brand capitalization on the My Account → Subscription page.
89
* Fix - Displays a specific message when an authentication error occurs during checkout for 3DS cards (shortcode version).

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ public function should_show_express_checkout_button() {
585585
( is_product() && ! $this->product_needs_shipping( $this->get_product() ) ) ||
586586
( ( is_cart() || is_checkout() ) && ! WC()->cart->needs_shipping() )
587587
) &&
588+
wc_tax_enabled() &&
588589
in_array( get_option( 'woocommerce_tax_based_on' ), [ 'billing', 'shipping' ], true )
589590
) {
590591
return false;

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
113113
= 8.9.0 - xxxx-xx-xx =
114114
* Tweak - Makes the new Stripe Express Checkout Element enabled by default.
115115
* Dev - Add multiple unit tests for the Stripe Express Checkout Element implementation (for both frontend and backend).
116+
* Fix - Check if taxes are enabled when applying ECE tax compatibility check.
116117
* Fix - Fix ECE error when initial address on load is not defined as a shipping zone.
117118
* Fix - Corrected card brand capitalization on the My Account → Subscription page.
118119
* Fix - Displays a specific message when an authentication error occurs during checkout for 3DS cards (shortcode version).

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ public function set_up() {
1919
$stripe_settings['test_publishable_key'] = 'pk_test_key';
2020
$stripe_settings['test_secret_key'] = 'sk_test_key';
2121
WC_Stripe_Helper::update_main_stripe_settings( $stripe_settings );
22+
23+
// Add a shipping zone.
24+
$zone = new WC_Shipping_Zone();
25+
$zone->set_zone_name( 'Worldwide' );
26+
$zone->set_zone_order( 1 );
27+
$zone->save();
28+
29+
$flat_rate_id = $zone->add_shipping_method( 'flat_rate' );
30+
$method = WC_Shipping_Zones::get_shipping_method( $flat_rate_id );
31+
$option_key = $method->get_instance_option_key();
32+
$options['cost'] = '5';
33+
update_option( $option_key, $options );
2234
}
2335

2436
/**
@@ -52,17 +64,24 @@ public function test_hides_ece_if_cannot_compute_taxes() {
5264
WC()->cart->add_to_cart( $virtual_product->get_id(), 1 );
5365

5466
// Hide if cart has virtual product and tax is based on shipping or billing address.
67+
update_option( 'woocommerce_calc_taxes', 'yes' );
5568
update_option( 'woocommerce_tax_based_on', 'billing' );
5669
$this->assertFalse( $wc_stripe_ece_helper_mock->should_show_express_checkout_button() );
5770

5871
update_option( 'woocommerce_tax_based_on', 'shipping' );
5972
$this->assertFalse( $wc_stripe_ece_helper_mock->should_show_express_checkout_button() );
6073

74+
// Do not hide if taxes are not enabled.
75+
update_option( 'woocommerce_calc_taxes', 'no' );
76+
$this->assertTrue( $wc_stripe_ece_helper_mock->should_show_express_checkout_button() );
77+
6178
// Do not hide if taxes are not based on customer billing or shipping address.
79+
update_option( 'woocommerce_calc_taxes', 'yes' );
6280
update_option( 'woocommerce_tax_based_on', 'base' );
6381
$this->assertTrue( $wc_stripe_ece_helper_mock->should_show_express_checkout_button() );
6482

6583
// Do not hide if cart requires shipping.
84+
update_option( 'woocommerce_tax_based_on', 'billing' );
6685
$shippable_product = WC_Helper_Product::create_simple_product();
6786
WC()->cart->add_to_cart( $shippable_product->get_id(), 1 );
6887
$this->assertTrue( $wc_stripe_ece_helper_mock->should_show_express_checkout_button() );

0 commit comments

Comments
 (0)