diff --git a/includes/model/class-product.php b/includes/model/class-product.php index d2e8b1fe..fe65ff62 100644 --- a/includes/model/class-product.php +++ b/includes/model/class-product.php @@ -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() { diff --git a/tests/wpunit/QLSessionHandlerTest.php b/tests/wpunit/QLSessionHandlerTest.php index 23b491a9..e7aaddd4 100644 --- a/tests/wpunit/QLSessionHandlerTest.php +++ b/tests/wpunit/QLSessionHandlerTest.php @@ -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() ); }