Adds tax calculation to regular and sale prices. (#714)

* Adds tax calculation to regular and sale prices.

* fixup! Adds tax calculation to regular and sale prices.

* Fix phpunit deprecated method.

* fixup! Fix phpunit deprecated method.

* fixup! fixup! Fix phpunit deprecated method.

* Fix missing param in function.

* Fix linting.

---------

Co-authored-by: Andres A <andres@Andress-MBP.home>
This commit is contained in:
Andres
2023-03-10 13:46:39 -05:00
committed by GitHub
co-authored by Andres A
parent e4f7da8fdb
commit bde5fc5bbd
2 changed files with 15 additions and 8 deletions
+9 -2
View File
@@ -245,7 +245,7 @@ class Product extends WC_Post {
},
'regularPrice' => function() {
return ! empty( $this->wc_data->get_regular_price() )
? \wc_graphql_price( $this->wc_data->get_regular_price() )
? \wc_graphql_price( \wc_get_price_to_display( $this->wc_data, [ 'price' => $this->wc_data->get_regular_price() ] ) )
: null;
},
'regularPriceRaw' => function() {
@@ -253,7 +253,14 @@ class Product extends WC_Post {
},
'salePrice' => function() {
return ! empty( $this->wc_data->get_sale_price() )
? \wc_graphql_price( $this->wc_data->get_sale_price() )
? \wc_graphql_price(
\wc_get_price_to_display(
[
$this->wc_data,
'price' => $this->wc_data->get_sale_price(),
]
)
)
: null;
},
'salePriceRaw' => function() {
+6 -6
View File
@@ -74,9 +74,9 @@ class QLSessionHandlerTest extends \Tests\WPGraphQL\WooCommerce\TestCase\WooGrap
// Expect token to be value.
$token = $session->get_session_token();
$this->assertObjectHasAttribute( 'iat', $token );
$this->assertObjectHasAttribute( 'exp', $token );
$this->assertObjectHasAttribute( 'data', $token );
$this->assertTrue( ! empty( $token->iat ) );
$this->assertTrue( ! empty( $token->exp ) );
$this->assertTrue( ! empty( $token->data ) );
}
public function test_get_session_header() {
@@ -108,9 +108,9 @@ class QLSessionHandlerTest extends \Tests\WPGraphQL\WooCommerce\TestCase\WooGrap
$token = $session->build_token();
$decode_token = JWT::decode( $token, new Key( GRAPHQL_WOOCOMMERCE_SECRET_KEY, 'HS256' ) );
$this->assertObjectHasAttribute( 'iat', $decode_token );
$this->assertObjectHasAttribute( 'exp', $decode_token );
$this->assertObjectHasAttribute( 'data', $decode_token );
$this->assertTrue( ! empty( $decode_token->iat ) );
$this->assertTrue( ! empty( $decode_token->exp ) );
$this->assertTrue( ! empty( $decode_token->data ) );
$this->assertEquals( $token, $session->build_token() );
}