mirror of
https://github.com/wp-graphql/wp-graphql-woocommerce.git
synced 2026-08-14 12:53:44 +02:00
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:
@@ -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() {
|
||||
|
||||
@@ -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() );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user