Added Check For Tax Category

This commit is contained in:
devansh bawari 2021-05-31 11:42:31 +05:30
parent 5b6e37c6fc
commit 1206f9cc9f
3 changed files with 16 additions and 8 deletions

View File

@ -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.
*

View File

@ -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())
<div>
{{ __('shop::app.products.tax-inclusive') }}
</div>

View File

@ -126,7 +126,7 @@
<div class="col-12 price">
@include ('shop::products.price', ['product' => $product])
@if (Webkul\Tax\Helpers\Tax::isTaxInclusive())
@if (Webkul\Tax\Helpers\Tax::isTaxInclusive() && $product->getTypeInstance()->getTaxCategory())
<span>
{{ __('velocity::app.products.tax-inclusive') }}
</span>