Skip to content

Commit 06d6c04

Browse files
authored
Using the new tax status constants (#4302)
* Using the new tax status constants * Changelog and readme entries * Changelog and readme updates * Replacing occurrences in unit tests
1 parent 374da44 commit 06d6c04

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*** Changelog ***
22

33
= 9.8.0 - xxxx-xx-xx =
4+
* Dev - Implements WooCommerce constants for the tax statuses
45
* Add - Adds the current setting value for the Optimized Checkout to the Stripe System Status Report data
56
* Add - A new pill to the payment methods page to indicate the credit card requirement when the Optimized Checkout feature is enabled
67
* Add - Tracks the toggle of the Optimized Checkout feature in the promotional banner

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use Automattic\WooCommerce\Enums\ProductType;
4+
use Automattic\WooCommerce\Enums\ProductTaxStatus;
45

56
if ( ! defined( 'ABSPATH' ) ) {
67
exit;
@@ -765,7 +766,7 @@ private function is_product_or_cart_taxable() {
765766
if ( ! $product ) {
766767
return false;
767768
}
768-
return $product->get_tax_status() !== 'none';
769+
return $product->get_tax_status() !== ProductTaxStatus::NONE;
769770
}
770771

771772
// Cart or checkout page: the cart is taxable if any item in the cart
@@ -782,7 +783,7 @@ private function is_product_or_cart_taxable() {
782783
$cart_item_key
783784
);
784785

785-
if ( 'none' !== $product->get_tax_status() ) {
786+
if ( ProductTaxStatus::NONE !== $product->get_tax_status() ) {
786787
return true;
787788
}
788789
}

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
111111
== Changelog ==
112112

113113
= 9.8.0 - xxxx-xx-xx =
114+
* Dev - Implements WooCommerce constants for the tax statuses
114115
* Add - Adds the current setting value for the Optimized Checkout to the Stripe System Status Report data
115116
* Add - A new pill to the payment methods page to indicate the credit card requirement when the Optimized Checkout feature is enabled
116117
* Add - Tracks the toggle of the Optimized Checkout feature in the promotional banner

tests/phpunit/Helpers/WC_Helper_Product.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace WooCommerce\Stripe\Tests\Helpers;
44

5+
use Automattic\WooCommerce\Enums\ProductTaxStatus;
56
use WC_Cache_Helper;
67
use WC_Product_Attribute;
78
use WC_Product_External;
@@ -50,7 +51,7 @@ public static function create_simple_product( $save = true, $props = [] ) {
5051
'price' => 10,
5152
'sku' => 'DUMMY SKU',
5253
'manage_stock' => false,
53-
'tax_status' => 'taxable',
54+
'tax_status' => ProductTaxStatus::TAXABLE,
5455
'downloadable' => false,
5556
'virtual' => false,
5657
'stock_status' => 'instock',

tests/phpunit/Helpers/WC_Helper_Shipping.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace WooCommerce\Stripe\Tests\Helpers;
44

5+
use Automattic\WooCommerce\Enums\ProductTaxStatus;
56
use WC_Cache_Helper;
67

78
/**
@@ -28,7 +29,7 @@ public static function create_simple_flat_rate( $cost = 10 ) {
2829
'title' => 'Flat rate',
2930
'availability' => 'all',
3031
'countries' => '',
31-
'tax_status' => 'taxable',
32+
'tax_status' => ProductTaxStatus::TAXABLE,
3233
'cost' => $cost,
3334
];
3435

tests/phpunit/PaymentMethods/WC_Stripe_Express_Checkout_Helper_Test.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace WooCommerce\Stripe\Tests\PaymentMethods;
44

5+
use Automattic\WooCommerce\Enums\ProductTaxStatus;
56
use WC_Gateway_Stripe;
67
use WC_Stripe_UPE_Payment_Gateway;
78
use WC_Gateway_Stripe_Alipay;
@@ -163,17 +164,17 @@ private function create_products_for_test_hides_ece_if_cannot_compute_taxes() {
163164

164165
$virtual_nontaxable_product = WC_Helper_Product::create_simple_product();
165166
$virtual_nontaxable_product->set_virtual( true );
166-
$virtual_nontaxable_product->set_tax_status( 'none' );
167+
$virtual_nontaxable_product->set_tax_status( ProductTaxStatus::NONE );
167168
$virtual_nontaxable_product->save();
168169

169170
$virtual_taxable_product = WC_Helper_Product::create_simple_product();
170171
$virtual_taxable_product->set_virtual( true );
171-
$virtual_taxable_product->set_tax_status( 'taxable' );
172+
$virtual_taxable_product->set_tax_status( ProductTaxStatus::TAXABLE );
172173
$virtual_taxable_product->save();
173174

174175
$shippable_taxable_product = WC_Helper_Product::create_simple_product();
175176
$shippable_taxable_product->set_virtual( false );
176-
$shippable_taxable_product->set_tax_status( 'taxable' );
177+
$shippable_taxable_product->set_tax_status( ProductTaxStatus::TAXABLE );
177178
$shippable_taxable_product->save();
178179
$this->products = [
179180
'virtual_nontaxable' => $virtual_nontaxable_product,
@@ -291,7 +292,7 @@ public function test_hides_ece_if_stripe_gateway_unavailable() {
291292
// Add a non-taxable product to the cart.
292293
$product = WC_Helper_Product::create_simple_product();
293294
$product->set_virtual( false );
294-
$product->set_tax_status( 'none' );
295+
$product->set_tax_status( ProductTaxStatus::NONE );
295296
$product->save();
296297

297298
WC()->session->init();

0 commit comments

Comments
 (0)