Skip to content

Commit bde5fc5

Browse files
creative-andrewAndres A
andauthored
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 <[email protected]>
1 parent e4f7da8 commit bde5fc5

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

includes/model/class-product.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,22 @@ protected function init() {
245245
},
246246
'regularPrice' => function() {
247247
return ! empty( $this->wc_data->get_regular_price() )
248-
? \wc_graphql_price( $this->wc_data->get_regular_price() )
248+
? \wc_graphql_price( \wc_get_price_to_display( $this->wc_data, [ 'price' => $this->wc_data->get_regular_price() ] ) )
249249
: null;
250250
},
251251
'regularPriceRaw' => function() {
252252
return ! empty( $this->wc_data->get_regular_price() ) ? $this->wc_data->get_regular_price() : null;
253253
},
254254
'salePrice' => function() {
255255
return ! empty( $this->wc_data->get_sale_price() )
256-
? \wc_graphql_price( $this->wc_data->get_sale_price() )
256+
? \wc_graphql_price(
257+
\wc_get_price_to_display(
258+
[
259+
$this->wc_data,
260+
'price' => $this->wc_data->get_sale_price(),
261+
]
262+
)
263+
)
257264
: null;
258265
},
259266
'salePriceRaw' => function() {

tests/wpunit/QLSessionHandlerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ public function test_get_session_token() {
7474

7575
// Expect token to be value.
7676
$token = $session->get_session_token();
77-
$this->assertObjectHasAttribute( 'iat', $token );
78-
$this->assertObjectHasAttribute( 'exp', $token );
79-
$this->assertObjectHasAttribute( 'data', $token );
77+
$this->assertTrue( ! empty( $token->iat ) );
78+
$this->assertTrue( ! empty( $token->exp ) );
79+
$this->assertTrue( ! empty( $token->data ) );
8080
}
8181

8282
public function test_get_session_header() {
@@ -108,9 +108,9 @@ public function test_build_token() {
108108
$token = $session->build_token();
109109

110110
$decode_token = JWT::decode( $token, new Key( GRAPHQL_WOOCOMMERCE_SECRET_KEY, 'HS256' ) );
111-
$this->assertObjectHasAttribute( 'iat', $decode_token );
112-
$this->assertObjectHasAttribute( 'exp', $decode_token );
113-
$this->assertObjectHasAttribute( 'data', $decode_token );
111+
$this->assertTrue( ! empty( $decode_token->iat ) );
112+
$this->assertTrue( ! empty( $decode_token->exp ) );
113+
$this->assertTrue( ! empty( $decode_token->data ) );
114114

115115
$this->assertEquals( $token, $session->build_token() );
116116
}

0 commit comments

Comments
 (0)