diff --git a/packages/Webkul/Admin/src/Resources/views/layouts/master.blade.php b/packages/Webkul/Admin/src/Resources/views/layouts/master.blade.php
index 47211d650..7ffa75817 100755
--- a/packages/Webkul/Admin/src/Resources/views/layouts/master.blade.php
+++ b/packages/Webkul/Admin/src/Resources/views/layouts/master.blade.php
@@ -1,7 +1,3 @@
-@php
- $locale = Webkul\Core\Models\Locale::where('code', app()->getLocale())->first();
-@endphp
-
@@ -23,7 +19,7 @@
- direction == 'rtl') class="rtl" @endif style="scroll-behavior: smooth;">
+ getCurrentLocale()->direction == 'rtl') class="rtl" @endif style="scroll-behavior: smooth;">
{!! view_render_event('bagisto.admin.layout.body.before') !!}
diff --git a/packages/Webkul/Category/src/Database/Migrations/2019_07_31_143339_create_category_filterable_attributes_table.php b/packages/Webkul/Category/src/Database/Migrations/2019_07_31_143339_create_category_filterable_attributes_table.php
new file mode 100644
index 000000000..3301581ad
--- /dev/null
+++ b/packages/Webkul/Category/src/Database/Migrations/2019_07_31_143339_create_category_filterable_attributes_table.php
@@ -0,0 +1,33 @@
+integer('category_id')->unsigned();
+ $table->integer('attribute_id')->unsigned();
+ $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
+ $table->foreign('attribute_id')->references('id')->on('attributes')->onDelete('cascade');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('category_filterable_attributes');
+ }
+}
diff --git a/packages/Webkul/Category/src/Http/Controllers/CategoryController.php b/packages/Webkul/Category/src/Http/Controllers/CategoryController.php
index 2c5a876f5..8268c2187 100755
--- a/packages/Webkul/Category/src/Http/Controllers/CategoryController.php
+++ b/packages/Webkul/Category/src/Http/Controllers/CategoryController.php
@@ -5,6 +5,7 @@ namespace Webkul\Category\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Webkul\Category\Repositories\CategoryRepository as Category;
+use Webkul\Attribute\Repositories\AttributeRepository as Attribute;
use Webkul\Category\Models\CategoryTranslation;
use Illuminate\Support\Facades\Event;
@@ -30,16 +31,26 @@ class CategoryController extends Controller
*/
protected $category;
+ /**
+ * AttributeRepository object
+ *
+ * @var array
+ */
+ protected $attribute;
+
/**
* Create a new controller instance.
*
- * @param \Webkul\Category\Repositories\CategoryRepository $category
+ * @param \Webkul\Category\Repositories\CategoryRepository $category
+ * @param use Webkul\Attribute\Repositories\AttributeRepository $attribute
* @return void
*/
- public function __construct(Category $category)
+ public function __construct(Category $category, Attribute $attribute)
{
$this->category = $category;
+ $this->attribute = $attribute;
+
$this->_config = request('_config');
}
@@ -62,7 +73,9 @@ class CategoryController extends Controller
{
$categories = $this->category->getCategoryTree(null, ['id']);
- return view($this->_config['view'], compact('categories'));
+ $attributes = $this->attribute->findWhere(['is_filterable' => 1]);
+
+ return view($this->_config['view'], compact('categories', 'attributes'));
}
/**
@@ -110,7 +123,9 @@ class CategoryController extends Controller
$category = $this->category->findOrFail($id);
- return view($this->_config['view'], compact('category', 'categories'));
+ $attributes = $this->attribute->findWhere(['is_filterable' => 1]);
+
+ return view($this->_config['view'], compact('category', 'categories', 'attributes'));
}
/**
diff --git a/packages/Webkul/Category/src/Models/Category.php b/packages/Webkul/Category/src/Models/Category.php
index 48b8e3046..8a38f7c02 100755
--- a/packages/Webkul/Category/src/Models/Category.php
+++ b/packages/Webkul/Category/src/Models/Category.php
@@ -6,6 +6,7 @@ use Webkul\Core\Eloquent\TranslatableModel;
use Kalnoy\Nestedset\NodeTrait;
use Illuminate\Support\Facades\Storage;
use Webkul\Category\Contracts\Category as CategoryContract;
+use Webkul\Attribute\Models\AttributeProxy;
class Category extends TranslatableModel implements CategoryContract
{
@@ -35,4 +36,12 @@ class Category extends TranslatableModel implements CategoryContract
{
return $this->image_url();
}
+
+ /**
+ * The filterable attributes that belong to the category.
+ */
+ public function filterableAttributes()
+ {
+ return $this->belongsToMany(AttributeProxy::modelClass(), 'category_filterable_attributes')->with('options');
+ }
}
\ No newline at end of file
diff --git a/packages/Webkul/Category/src/Repositories/CategoryRepository.php b/packages/Webkul/Category/src/Repositories/CategoryRepository.php
index ccae2f210..3ddf7f649 100755
--- a/packages/Webkul/Category/src/Repositories/CategoryRepository.php
+++ b/packages/Webkul/Category/src/Repositories/CategoryRepository.php
@@ -63,6 +63,10 @@ class CategoryRepository extends Repository
$this->uploadImages($data, $category);
+ if (isset($data['attributes'])) {
+ $category->filterableAttributes()->sync($data['attributes']);
+ }
+
Event::fire('catalog.category.create.after', $category);
return $category;
@@ -163,6 +167,10 @@ class CategoryRepository extends Repository
$this->uploadImages($data, $category);
+ if (isset($data['attributes'])) {
+ $category->filterableAttributes()->sync($data['attributes']);
+ }
+
Event::fire('catalog.category.update.after', $id);
return $category;
diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php
index 523ec26c5..6bbb39e25 100755
--- a/packages/Webkul/Checkout/src/Cart.php
+++ b/packages/Webkul/Checkout/src/Cart.php
@@ -936,27 +936,35 @@ class Cart {
'country' => $shippingAddress->country,
])->orderBy('tax_rate', 'desc')->get();
- foreach ($taxRates as $rate) {
- $haveTaxRate = false;
+ if (count( $taxRates) > 0) {
+ foreach ($taxRates as $rate) {
+ $haveTaxRate = false;
- if (! $rate->is_zip) {
- if ($rate->zip_code == '*' || $rate->zip_code == $shippingAddress->postcode) {
- $haveTaxRate = true;
+ if (! $rate->is_zip) {
+ if ($rate->zip_code == '*' || $rate->zip_code == $shippingAddress->postcode) {
+ $haveTaxRate = true;
+ }
+ } else {
+ if ($shippingAddress->postcode >= $rate->zip_from && $shippingAddress->postcode <= $rate->zip_to) {
+ $haveTaxRate = true;
+ }
}
- } else {
- if ($shippingAddress->postcode >= $rate->zip_from && $shippingAddress->postcode <= $rate->zip_to) {
- $haveTaxRate = true;
+
+ if ($haveTaxRate) {
+ $item->tax_percent = $rate->tax_rate;
+ $item->tax_amount = ($item->total * $rate->tax_rate) / 100;
+ $item->base_tax_amount = ($item->base_total * $rate->tax_rate) / 100;
+
+ $item->save();
+ break;
}
}
+ } else {
+ $item->tax_percent = 0;
+ $item->tax_amount = 0;
+ $item->base_tax_amount = 0;
- if ($haveTaxRate) {
- $item->tax_percent = $rate->tax_rate;
- $item->tax_amount = ($item->total * $rate->tax_rate) / 100;
- $item->base_tax_amount = ($item->base_total * $rate->tax_rate) / 100;
-
- $item->save();
- break;
- }
+ $item->save();
}
}
}
diff --git a/packages/Webkul/Product/src/Listeners/ProductFlat.php b/packages/Webkul/Product/src/Listeners/ProductFlat.php
index 5de64312e..5cbfc80a9 100644
--- a/packages/Webkul/Product/src/Listeners/ProductFlat.php
+++ b/packages/Webkul/Product/src/Listeners/ProductFlat.php
@@ -104,6 +104,7 @@ class ProductFlat
public function afterAttributeCreatedUpdated($attribute)
{
if (! $attribute->is_user_defined || ! $attribute->use_in_flat) {
+ $this->afterAttributeDeleted($attribute->id);
return false;
}
diff --git a/packages/Webkul/Shop/src/Resources/views/layouts/master.blade.php b/packages/Webkul/Shop/src/Resources/views/layouts/master.blade.php
index 190b3df2e..6d01be266 100755
--- a/packages/Webkul/Shop/src/Resources/views/layouts/master.blade.php
+++ b/packages/Webkul/Shop/src/Resources/views/layouts/master.blade.php
@@ -1,7 +1,3 @@
-@php
- $locale = Webkul\Core\Models\Locale::where('code', app()->getLocale())->first();
-@endphp
-
@@ -34,7 +30,8 @@
-direction == 'rtl') class="rtl" @endif style="scroll-behavior: smooth;">
+
+getCurrentLocale()->direction == 'rtl') class="rtl" @endif style="scroll-behavior: smooth;">
{!! view_render_event('bagisto.shop.layout.body.before') !!}
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 7ef798090..e15147b98 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
@@ -2,24 +2,26 @@
@inject ('productFlatRepository', 'Webkul\Product\Repositories\ProductFlatRepository')
-@inject ('productAttributeValueRepository', 'Webkul\Product\Repositories\ProductAttributeValueRepository')
-
getCategoryProductAttribute($category->id);
+ if (count($category->filterableAttributes) > 0) {
+ $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;
+ 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 = collect($filterAttributes);
+ }
}
} else {
$filterAttributes = $attributeRepository->getFilterAttributes();
From 6f64de0f2637b993969f452f3c73c23932c9c2a9 Mon Sep 17 00:00:00 2001
From: rahul shukla
Date: Wed, 31 Jul 2019 19:19:26 +0530
Subject: [PATCH 31/32] issue #1235
---
.../src/Resources/views/catalog/categories/create.blade.php | 2 +-
.../Admin/src/Resources/views/catalog/categories/edit.blade.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/packages/Webkul/Admin/src/Resources/views/catalog/categories/create.blade.php b/packages/Webkul/Admin/src/Resources/views/catalog/categories/create.blade.php
index 387de9164..8c816b1af 100755
--- a/packages/Webkul/Admin/src/Resources/views/catalog/categories/create.blade.php
+++ b/packages/Webkul/Admin/src/Resources/views/catalog/categories/create.blade.php
@@ -143,7 +143,7 @@
diff --git a/packages/Webkul/Admin/src/Resources/views/catalog/categories/edit.blade.php b/packages/Webkul/Admin/src/Resources/views/catalog/categories/edit.blade.php
index 4c4fe5880..f3c37f7e1 100755
--- a/packages/Webkul/Admin/src/Resources/views/catalog/categories/edit.blade.php
+++ b/packages/Webkul/Admin/src/Resources/views/catalog/categories/edit.blade.php
@@ -155,7 +155,7 @@
From 9ba2357d7c33a7b844bfa3ada9b2bc46cdce16c0 Mon Sep 17 00:00:00 2001
From: rahul shukla
Date: Thu, 1 Aug 2019 10:22:23 +0530
Subject: [PATCH 32/32] reverting changes, delete for product_attribute in
product flat
---
packages/Webkul/Product/src/Listeners/ProductFlat.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/packages/Webkul/Product/src/Listeners/ProductFlat.php b/packages/Webkul/Product/src/Listeners/ProductFlat.php
index 5cbfc80a9..07008b11a 100644
--- a/packages/Webkul/Product/src/Listeners/ProductFlat.php
+++ b/packages/Webkul/Product/src/Listeners/ProductFlat.php
@@ -103,7 +103,11 @@ class ProductFlat
*/
public function afterAttributeCreatedUpdated($attribute)
{
- if (! $attribute->is_user_defined || ! $attribute->use_in_flat) {
+ if (! $attribute->is_user_defined) {
+ return false;
+ }
+
+ if (! $attribute->use_in_flat) {
$this->afterAttributeDeleted($attribute->id);
return false;
}