diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index 1309b9839..f293aea7f 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -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 * diff --git a/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php b/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php index ee937894e..2d2295854 100644 --- a/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php @@ -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; + } } \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php index 300287d2b..a133d353c 100755 --- a/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php @@ -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() { diff --git a/packages/Webkul/Shop/src/Resources/views/products/list/layered-navigation.blade.php b/packages/Webkul/Shop/src/Resources/views/products/list/layered-navigation.blade.php index 995727f94..6cd7262b9 100755 --- a/packages/Webkul/Shop/src/Resources/views/products/list/layered-navigation.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/list/layered-navigation.blade.php @@ -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(); } diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage.blade.php index f7b563ddd..184323563 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage.blade.php @@ -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() { diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/products/list/layered-navigation.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/products/list/layered-navigation.blade.php index 015826c4e..632bdfaaa 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/products/list/layered-navigation.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/products/list/layered-navigation.blade.php @@ -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); ?>