diff --git a/src/Price.php b/src/Price.php index 7eab132..e2f19e0 100644 --- a/src/Price.php +++ b/src/Price.php @@ -83,6 +83,16 @@ public function tax() return $this->formatAmount((int) ($this->rawTax() * 100)); } + /** + * Determine if the price has tax. + * + * @return boolean + */ + public function hasTax() + { + return $this->rawTax() > 0; + } + /** * Get the raw tax amount. * diff --git a/tests/Unit/ProductPriceTest.php b/tests/Unit/ProductPriceTest.php index 7936623..475b947 100644 --- a/tests/Unit/ProductPriceTest.php +++ b/tests/Unit/ProductPriceTest.php @@ -85,6 +85,13 @@ public function test_it_implements_arrayable_and_jsonable() $this->assertSame($data, $product->jsonSerialize()); $this->assertSame(json_encode($data), $product->toJson()); } + + public function test_it_can_check_if_has_tax() + { + $product = $this->product(); + + $this->assertTrue($product->price()->hasTax()); + } /** * Get a test product price object.