This commit is contained in:
prateek srivastava 2020-02-19 16:26:06 +05:30
commit e1cdff607b
6 changed files with 69 additions and 46 deletions

View File

@ -738,8 +738,11 @@ class Cart {
foreach ($taxRates as $rate) {
$haveTaxRate = false;
if ($rate->state != '' && $rate->state != $address->state)
if ($rate->state != '' && $rate->state != $address->state) {
$this->setItemTaxToZero($item);
continue;
}
if (! $rate->is_zip) {
if ($rate->zip_code == '*' || $rate->zip_code == $address->postcode)
@ -757,24 +760,30 @@ class Cart {
$item->save();
break;
} else {
$item->tax_percent = 0;
$item->tax_amount = 0;
$item->base_tax_amount = 0;
$this->setItemTaxToZero($item);
$item->save();
break;
}
}
} else {
$item->tax_percent = 0;
$item->tax_amount = 0;
$item->base_tax_amount = 0;
$item->save();
$this->setItemTaxToZero($item);
}
}
}
/**
* Set Item tax to zero.
*
* @return void
*/
protected function setItemTaxToZero($item) {
$item->tax_percent = 0;
$item->tax_amount = 0;
$item->base_tax_amount = 0;
$item->save();
}
/**
* Checks if cart has any error
*

View File

@ -35,8 +35,9 @@ class ProductFlatRepository extends Repository
}
/**
* get Category Product
* get Category Product Attribute
*
* @param CategoryId $categoryId
* @return array
*/
public function getCategoryProductAttribute($categoryId)
@ -61,4 +62,35 @@ class ProductFlatRepository extends Repository
return $productCategoryArrributes;
}
/**
* get Filterable Attributes.
*
* @param array $category
* @param array $products
* @return collection
*/
public function getFilterableAttributes($category, $products) {
$filterAttributes = [];
if (count($category->filterableAttributes) > 0 && count($products)) {
$filterAttributes = $category->filterableAttributes;
} else {
$categoryProductAttributes = $this->getCategoryProductAttribute($category->id);
if ($categoryProductAttributes) {
foreach (app('Webkul\Attribute\Repositories\AttributeRepository')->getFilterAttributes() as $filterAttribute) {
if (in_array($filterAttribute->id, $categoryProductAttributes)) {
$filterAttributes[] = $filterAttribute;
} else if ($filterAttribute ['code'] == 'price') {
$filterAttributes[] = $filterAttribute;
}
}
$filterAttributes = collect($filterAttributes);
}
}
return $filterAttributes;
}
}

View File

@ -404,10 +404,12 @@
newBillingAddress: function() {
this.new_billing_address = true;
this.address.billing.address_id = null;
},
newShippingAddress: function() {
this.new_shipping_address = true;
this.address.shipping.address_id = null;
},
backToSavedBillingAddress: function() {

View File

@ -10,23 +10,7 @@
if (isset($category)) {
$products = $productRepository->getAll($category->id);
if (count($category->filterableAttributes) > 0 && count($products)) {
$filterAttributes = $category->filterableAttributes;
} else {
$categoryProductAttributes = $productFlatRepository->getCategoryProductAttribute($category->id);
if ($categoryProductAttributes) {
foreach ($attributeRepository->getFilterAttributes() as $filterAttribute) {
if (in_array($filterAttribute->id, $categoryProductAttributes)) {
$filterAttributes[] = $filterAttribute;
} else if ($filterAttribute ['code'] == 'price') {
$filterAttributes[] = $filterAttribute;
}
}
$filterAttributes = collect($filterAttributes);
}
}
$filterAttributes = $productFlatRepository->getFilterableAttributes($category, $products);
} else {
$filterAttributes = $attributeRepository->getFilterAttributes();
}

View File

@ -478,7 +478,7 @@
newBillingAddress: function() {
this.new_billing_address = true;
this.isPlaceOrderEnabled = false;
this.address.shipping.address_id = null;
this.address.billing.address_id = null;
},
newShippingAddress: function() {

View File

@ -8,26 +8,22 @@
if (isset($category)) {
$products = $productRepository->getAll($category->id);
if (count($category->filterableAttributes) > 0 && count($products)) {
$filterAttributes = $category->filterableAttributes;
} else {
$categoryProductAttributes = $productFlatRepository->getCategoryProductAttribute($category->id);
if ($categoryProductAttributes) {
foreach ($attributeRepository->getFilterAttributes() as $filterAttribute) {
if (in_array($filterAttribute->id, $categoryProductAttributes)) {
$filterAttributes[] = $filterAttribute;
} else if ($filterAttribute ['code'] == 'price') {
$filterAttributes[] = $filterAttribute;
}
}
$filterAttributes = collect($filterAttributes);
}
}
$filterAttributes = $productFlatRepository->getFilterableAttributes($category, $products);
} else {
$filterAttributes = $attributeRepository->getFilterAttributes();
}
foreach ($filterAttributes as $attribute) {
if ($attribute->code <> 'price') {
if (! $attribute->options->isEmpty()) {
$attributes[] = $attribute;
}
} else {
$attributes[] = $attribute;
}
}
$filterAttributes = collect($attributes);
?>
<div class="layered-filter-wrapper left">