diff --git a/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php
index 14ff10f32..cf1f7b562 100755
--- a/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php
+++ b/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php
@@ -52,11 +52,11 @@ class LocalesDataGrid extends DataGrid
'sortable' => true,
'filterable' => true
]);
-
+
$this->addColumn([
'index' => 'direction',
'label' => trans('admin::app.datagrid.direction'),
- 'type' => 'select',
+ 'type' => 'string',
'searchable' => true,
'sortable' => true,
'filterable' => true
diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php
index a70ef5113..fa425e62a 100755
--- a/packages/Webkul/Admin/src/Resources/lang/en/app.php
+++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php
@@ -449,7 +449,7 @@ return [
'image' => 'Image',
'file' => 'File',
'checkbox' => 'Checkbox',
- 'use_in_flat' => "Create in Product Flat Table"
+ 'use_in_flat' => "Create in Product Flat Table",
],
'families' => [
'title' => 'Families',
@@ -493,6 +493,8 @@ return [
'meta_description' => 'Meta Description',
'meta_keywords' => 'Meta Keywords',
'image' => 'Image',
+ 'filterable-attributes' => 'Filterable Attributes',
+ 'attributes' => 'Attributes',
]
],
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 69485ed92..387de9164 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
@@ -136,6 +136,23 @@
@endif
+
+
+
+
+
+
+ @{{ errors.first('attributes[]') }}
+
+
+
+
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.seo.before') !!}
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 1399593e1..4c4fe5880 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
@@ -148,6 +148,23 @@
@endif
+
+
+
+
+
+
+ @{{ errors.first('attributes[]') }}
+
+
+
+
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.seo.before', ['category' => $category]) !!}
diff --git a/packages/Webkul/Admin/src/Resources/views/layouts/anonymous-master.blade.php b/packages/Webkul/Admin/src/Resources/views/layouts/anonymous-master.blade.php
index 1cc7a63d9..5ac3d67ba 100755
--- a/packages/Webkul/Admin/src/Resources/views/layouts/anonymous-master.blade.php
+++ b/packages/Webkul/Admin/src/Resources/views/layouts/anonymous-master.blade.php
@@ -1,7 +1,3 @@
-@php
- $locale = Webkul\Core\Models\Locale::where('code', app()->getLocale())->first();
-@endphp
-
@@ -71,7 +67,7 @@
{!! view_render_event('bagisto.admin.layout.head') !!}
- direction == 'rtl') class="rtl" @endif style="scroll-behavior: smooth;">
+ getCurrentLocale()->direction == 'rtl') class="rtl" @endif style="scroll-behavior: smooth;">
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();