diff --git a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php
index 08012cfb2..461e208b1 100644
--- a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php
+++ b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php
@@ -76,31 +76,31 @@ class CategoryDataGrid
'columns' => [
[
'name' => 'cat.id',
- 'alias' => 'catID',
+ 'alias' => 'cat_id',
'type' => 'number',
'label' => 'Category ID',
'sortable' => true,
], [
'name' => 'ct.name',
- 'alias' => 'catName',
+ 'alias' => 'cat_name',
'type' => 'string',
'label' => 'Category Name',
'sortable' => false,
], [
'name' => 'cat.position',
- 'alias' => 'catPosition',
+ 'alias' => 'cat_position',
'type' => 'string',
'label' => 'Category Position',
'sortable' => false,
], [
'name' => 'cta.name',
- 'alias' => 'parentName',
+ 'alias' => 'parent_name',
'type' => 'string',
'label' => 'Parent Name',
'sortable' => true,
], [
'name' => 'cat.status',
- 'alias' => 'catStatus',
+ 'alias' => 'cat_status',
'type' => 'string',
'label' => 'Visible in Menu',
'sortable' => true,
@@ -110,8 +110,17 @@ class CategoryDataGrid
else
return "True";
},
- ],
-
+ ], [
+ 'name' => 'cta.locale',
+ 'alias' => 'cat_locale',
+ 'type' => 'string',
+ 'label' => 'Locale',
+ 'sortable' => true,
+ 'filter' => [
+ 'function' => 'where',
+ 'condition' => ['cta.locale', app()->getLocale()]
+ ],
+ ]
],
'filterable' => [
diff --git a/packages/Webkul/Admin/src/Providers/EventServiceProvider.php b/packages/Webkul/Admin/src/Providers/EventServiceProvider.php
index a9608eded..b3ce36c5f 100644
--- a/packages/Webkul/Admin/src/Providers/EventServiceProvider.php
+++ b/packages/Webkul/Admin/src/Providers/EventServiceProvider.php
@@ -165,7 +165,7 @@ class EventServiceProvider extends ServiceProvider
'icon-class' => '',
], [
'key' => 'settings.sliders',
- 'name' => 'Create Sliders',
+ 'name' => 'Sliders',
'route' => 'admin.sliders.index',
'sort' => 7,
'icon-class' => '',
diff --git a/packages/Webkul/Category/src/Repositories/CategoryRepository.php b/packages/Webkul/Category/src/Repositories/CategoryRepository.php
index d4574759b..d54b1db53 100644
--- a/packages/Webkul/Category/src/Repositories/CategoryRepository.php
+++ b/packages/Webkul/Category/src/Repositories/CategoryRepository.php
@@ -74,6 +74,19 @@ class CategoryRepository extends Repository
: Category::orderBy('position', 'ASC')->get()->toTree();
}
+ /**
+ * get visible category tree
+ *
+ * @param integer $id
+ * @return mixed
+ */
+ public function getVisibleCategoryTree($id = null)
+ {
+ return $id
+ ? Category::orderBy('position', 'ASC')->where('id', '!=', $id)->where('status', '=', '1')->get()->toTree()
+ : Category::orderBy('position', 'ASC')->where('status', '=', '1')->get()->toTree();
+ }
+
/**
* Checks slug is unique or not based on locale
*
diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php
index 9fa624860..c4840f822 100644
--- a/packages/Webkul/Checkout/src/Cart.php
+++ b/packages/Webkul/Checkout/src/Cart.php
@@ -123,6 +123,17 @@ class Cart {
$child = $childData = null;
if($product->type == 'configurable') {
$child = $this->product->findOneByField('id', $data['selected_configurable_option']);
+
+ $productAddtionalData = $this->getProductAttributeOptionDetails($child);
+
+ unset($productAddtionalData['html']);
+
+ $additional = [
+ 'request' => $data,
+ 'variant_id' => $data['selected_configurable_option'],
+ 'attributes' => $productAddtionalData
+ ];
+
$childData = [
'product_id' => $data['selected_configurable_option'],
'sku' => $child->sku,
@@ -145,7 +156,8 @@ class Cart {
'base_total' => $price * $data['quantity'],
'weight' => $weight = ($product->type == 'configurable' ? $child->weight : $product->weight),
'total_weight' => $weight * $data['quantity'],
- 'base_total_weight' => $weight * $data['quantity']
+ 'base_total_weight' => $weight * $data['quantity'],
+ 'additional' => json_encode($additional)
];
return ['parent' => $parentData, 'child' => $childData];
@@ -507,25 +519,51 @@ class Cart {
if($id == $item->id) {
if($item->type == "configurable") {
$canBe = $this->canAddOrUpdate($item->child->id, $quantity);
+
+ if($canBe == false) {
+ session()->flash('warning', trans('shop::app.checkout.cart.quantity.inventory_warning'));
+
+ return $cart;
+ }
+
+ $item->update([
+ 'quantity' => $quantity,
+ 'total' => core()->convertPrice($item->price * ($quantity)),
+ 'base_total' => $item->price * ($quantity),
+ 'total_weight' => $item->weight * ($quantity),
+ 'base_total_weight' => $item->weight * ($quantity)
+ ]);
} else {
$canBe = $this->canAddOrUpdate($id, $quantity);
+
+ if($canBe == false) {
+ session()->flash('warning', trans('shop::app.checkout.cart.quantity.inventory_warning'));
+
+ return $cart;
+ }
+ $prevQty = $item->quantity;
+
+ $item->update([
+ 'quantity' => $quantity,
+ 'total' => core()->convertPrice($item->price * ($quantity)),
+ 'base_total' => $item->price * ($quantity),
+ 'total_weight' => $item->weight * ($quantity),
+ 'base_total_weight' => $item->weight * ($quantity)
+ ]);
}
-
- if($canBe == false) {
- session()->flash('warning', trans('shop::app.checkout.cart.quantity.inventory_warning'));
-
- return $cart;
- }
-
- $item->update(['quantity' => $quantity]);
}
}
}
+ $this->collectTotals();
session()->flash('success', trans('shop::app.checkout.cart.quantity.success'));
- }
- return $cart;
+ return $cart;
+ } else {
+ session()->flash('warning', trans('shop::app.checkout.cart.integrity.missing_fields'));
+
+ return false;
+ }
}
/**
@@ -629,21 +667,22 @@ class Cart {
}
/**
- * Returns cart
+ * Returns the items details of the configurable and simple products
*
* @return Mixed
*/
- public function getItemAttributeOptionDetails($item)
+ public function getProductAttributeOptionDetails($product)
{
$data = [];
$labels = [];
- foreach($item->product->super_attributes as $attribute) {
- $option = $attribute->options()->where('id', $item->child->product->{$attribute->code})->first();
+ foreach($product->parent->super_attributes as $attribute) {
+ $option = $attribute->options()->where('id', $product->{$attribute->code})->first();
$data['attributes'][$attribute->code] = [
'attribute_name' => $attribute->name,
+ 'option_id' => $option->id,
'option_label' => $option->label,
];
@@ -756,6 +795,8 @@ class Cart {
if(!$cart = $this->getCart())
return false;
+ $this->validateItems();
+
$this->calculateItemsTax();
$cart->grand_total = $cart->base_grand_total = 0;
@@ -790,6 +831,60 @@ class Cart {
$cart->save();
}
+ /**
+ * To validate if the product information is changed by admin and the items have
+ * been added to the cart before it.
+ *
+ * @return boolean
+ */
+ public function validateItems() {
+ $cart = $this->getCart();
+
+ if(count($cart->items) == 0) {
+ $this->cart->delete($cart->id);
+
+ return redirect()->route('shop.home.index');
+ } else {
+ $items = $cart->items;
+
+ foreach($items as $item) {
+ if($item->product->type == 'configurable') {
+ if($item->product->sku != $item->sku) {
+ $item->update(['sku' => $item->product->sku]);
+
+ } else if($item->product->name != $item->name) {
+ $item->update(['name' => $item->product->name]);
+
+ } else if($item->child->product->price != $item->price) {
+ $item->update([
+ 'price' => $item->child->product->price,
+ 'base_price' => $item->child->product->price,
+ 'total' => core()->convertPrice($item->child->product->price * ($item->quantity)),
+ 'base_total' => $item->child->product->price * ($item->quantity),
+ ]);
+ }
+
+ } else if($item->product->type == 'simple') {
+ if($item->product->sku != $item->sku) {
+ $item->update(['sku' => $item->product->sku]);
+
+ } else if($item->product->name != $item->name) {
+ $item->update(['name' => $item->product->name]);
+
+ } else if($item->product->price != $item->price) {
+ $item->update([
+ 'price' => $item->product->price,
+ 'base_price' => $item->product->price,
+ 'total' => core()->convertPrice($item->child->product->price * ($item->quantity)),
+ 'base_total' => $item->child->product->price * ($item->quantity),
+ ]);
+ }
+ }
+ }
+ return true;
+ }
+ }
+
/**
* Calculates cart items tax
*
@@ -1044,6 +1139,16 @@ class Cart {
$price = ($product->type == 'configurable' ? $child->price : $product->price);
+ $productAddtionalData = $this->getProductAttributeOptionDetails($child);
+
+ unset($productAddtionalData['html']);
+
+ $additional = [
+ 'request' => $data,
+ 'variant_id' => $data['selected_configurable_option'],
+ 'attributes' => $productAddtionalData
+ ];
+
$parentData = [
'sku' => $product->sku,
'product_id' => $productId,
@@ -1056,7 +1161,8 @@ class Cart {
'base_total' => $price,
'weight' => $weight = ($product->type == 'configurable' ? $child->weight : $product->weight),
'total_weight' => $weight,
- 'base_total_weight' => $weight
+ 'base_total_weight' => $weight,
+ 'additional' => json_encode($additonal)
];
return ['parent' => $parentData, 'child' => $childData];
diff --git a/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php b/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php
index 67197fec6..9566805f3 100644
--- a/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php
+++ b/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php
@@ -67,12 +67,12 @@ class RegistrationController extends Controller
if ($this->customer->create($data)) {
- session()->flash('success', 'Account created successfully.');
+ session()->flash('success', 'Account Created Successfully');
return redirect()->route($this->_config['redirect']);
} else {
- session()->flash('error', 'Cannot Create Your Account.');
+ session()->flash('error', 'Cannot Create Your Account');
return redirect()->back();
}
diff --git a/packages/Webkul/Shop/src/Http/ViewComposers/CategoryComposer.php b/packages/Webkul/Shop/src/Http/ViewComposers/CategoryComposer.php
index c4885ea34..b9f59a470 100644
--- a/packages/Webkul/Shop/src/Http/ViewComposers/CategoryComposer.php
+++ b/packages/Webkul/Shop/src/Http/ViewComposers/CategoryComposer.php
@@ -44,7 +44,7 @@ class CategoryComposer
{
$categories = [];
- foreach ($this->category->getCategoryTree() as $category) {
+ foreach ($this->category->getVisibleCategoryTree() as $category) {
array_push($categories, collect($category));
}
diff --git a/packages/Webkul/Shop/src/Resources/assets/js/components/category-item.vue b/packages/Webkul/Shop/src/Resources/assets/js/components/category-item.vue
index 5c5ef5f18..d821519ca 100644
--- a/packages/Webkul/Shop/src/Resources/assets/js/components/category-item.vue
+++ b/packages/Webkul/Shop/src/Resources/assets/js/components/category-item.vue
@@ -1,4 +1,3 @@
-
{{ this.item['translations'][0].name }}
+