From 1206f9cc9fd4fb40035efe8057002eac98ddfc90 Mon Sep 17 00:00:00 2001 From: devansh bawari Date: Mon, 31 May 2021 11:42:31 +0530 Subject: [PATCH] Added Check For Tax Category --- .../Webkul/Product/src/Type/AbstractType.php | 20 +++++++++++++------ .../Resources/views/products/view.blade.php | 2 +- .../views/shop/products/view.blade.php | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/Webkul/Product/src/Type/AbstractType.php b/packages/Webkul/Product/src/Type/AbstractType.php index 850984fc0..adb4f19e3 100644 --- a/packages/Webkul/Product/src/Type/AbstractType.php +++ b/packages/Webkul/Product/src/Type/AbstractType.php @@ -758,18 +758,14 @@ abstract class AbstractType * Get inclusive tax rates. * * @param float $totalPrice - * @return array + * @return float */ public function getTaxInclusiveRate($totalPrice) { /* this is added for future purpose like if shipping tax also added then case is needed */ $address = null; - $taxCategoryId = $this->product->parent ? $this->product->parent->tax_category_id : $this->product->tax_category_id; - - $taxCategory = app(TaxCategoryRepository::class)->find($taxCategoryId); - - if ($taxCategory) { + if ($taxCategory = $this->getTaxCategory()) { if ($address === null && auth()->guard('customer')->check()) { $address = auth()->guard('customer')->user()->addresses()->where('default_address', 1)->first(); } @@ -786,6 +782,18 @@ abstract class AbstractType return $totalPrice; } + /** + * Get tax category. + * + * @return \Webkul\Tax\Models\TaxCategory + */ + public function getTaxCategory() + { + $taxCategoryId = $this->product->parent ? $this->product->parent->tax_category_id : $this->product->tax_category_id; + + return app(TaxCategoryRepository::class)->find($taxCategoryId); + } + /** * Evaluate price. * diff --git a/packages/Webkul/Shop/src/Resources/views/products/view.blade.php b/packages/Webkul/Shop/src/Resources/views/products/view.blade.php index 5ded2858d..8f0acfb36 100755 --- a/packages/Webkul/Shop/src/Resources/views/products/view.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/view.blade.php @@ -63,7 +63,7 @@ @include ('shop::products.price', ['product' => $product]) - @if (Webkul\Tax\Helpers\Tax::isTaxInclusive()) + @if (Webkul\Tax\Helpers\Tax::isTaxInclusive() && $product->getTypeInstance()->getTaxCategory())
{{ __('shop::app.products.tax-inclusive') }}
diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/products/view.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/products/view.blade.php index c3e08406f..9a3542eb0 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/products/view.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/products/view.blade.php @@ -126,7 +126,7 @@
@include ('shop::products.price', ['product' => $product]) - @if (Webkul\Tax\Helpers\Tax::isTaxInclusive()) + @if (Webkul\Tax\Helpers\Tax::isTaxInclusive() && $product->getTypeInstance()->getTaxCategory()) {{ __('velocity::app.products.tax-inclusive') }}