From 2721080a1b08941394235fe3295e27e7a1cc15e1 Mon Sep 17 00:00:00 2001 From: prashant-webkul Date: Thu, 20 Sep 2018 14:03:28 +0530 Subject: [PATCH 1/5] Just add more logics to cart and cart items from here --- packages/Webkul/Cart/src/Cart.php | 127 +++++++++++------- ..._09_05_150915_create_cart_items_table.php} | 2 +- .../src/Http/Controllers/CartController.php | 44 +++--- .../src/Http/ViewComposers/CartComposer.php | 29 +++- packages/Webkul/Cart/src/Models/Cart.php | 6 +- packages/Webkul/Cart/src/Models/CartItem.php | 17 +++ .../Webkul/Cart/src/Models/CartProduct.php | 11 -- .../src/Providers/CartServiceProvider.php | 9 +- ...tRepository.php => CartItemRepository.php} | 8 +- .../Cart/src/Repositories/CartRepository.php | 28 +++- packages/Webkul/Core/src/Core.php | 4 +- .../Criteria/AttributeToSelectCriteria.php | 4 +- .../src/Models/ProductAttributeValue.php | 2 +- packages/Webkul/Shop/src/Http/routes.php | 3 +- .../assets/js/components/cart-dropdown.vue | 2 + .../views/layouts/header/index.blade.php | 14 +- .../Resources/views/products/view.blade.php | 15 ++- 17 files changed, 216 insertions(+), 109 deletions(-) rename packages/Webkul/Cart/src/Database/migrations/{2018_09_05_150915_create_cart_products_table.php => 2018_09_05_150915_create_cart_items_table.php} (93%) create mode 100644 packages/Webkul/Cart/src/Models/CartItem.php delete mode 100644 packages/Webkul/Cart/src/Models/CartProduct.php rename packages/Webkul/Cart/src/Repositories/{CartProductRepository.php => CartItemRepository.php} (80%) diff --git a/packages/Webkul/Cart/src/Cart.php b/packages/Webkul/Cart/src/Cart.php index a580a8789..5f9555ff8 100644 --- a/packages/Webkul/Cart/src/Cart.php +++ b/packages/Webkul/Cart/src/Cart.php @@ -6,7 +6,7 @@ use Carbon\Carbon; //Cart repositories use Webkul\Cart\Repositories\CartRepository; -use Webkul\Cart\Repositories\CartProductRepository; +use Webkul\Cart\Repositories\CartItemRepository; //Customer repositories use Webkul\Customer\Repositories\CustomerRepository; @@ -24,67 +24,75 @@ use Cookie; class Cart { - protected $_config; - protected $cart; - protected $cartProduct; + protected $cartItem; protected $customer; //Cookie expiry limit in minutes - protected $minutes = 150; + protected $minutes; - public function __construct(CartRepository $cart, CartProductRepository $cartProduct, CustomerRepository $customer ,$minutes = 150) { + public function __construct(CartRepository $cart, CartItemRepository $cartItem, CustomerRepository $customer, $minutes = 150) { $this->customer = $customer; $this->cart = $cart; - $this->cartProduct = $cartProduct; + $this->cartItem = $cartItem; $this->minutes = $minutes; } - public function guestUnitAdd($id) { + public function guestUnitAdd($id, $data) { - //empty array for storing the products + //empty array for storing the products. $products = array(); if(Cookie::has('cart_session_id')) { - //getting the cart session id from cookie + //getting the cart session id from cookie. $cart_session_id = Cookie::get('cart_session_id'); //finding current cart instance in the database table. $current_cart = $this->cart->findOneByField('session_id', $cart_session_id); - //check there is any cart or not + //check there is any cart or not. if(isset($current_cart)) { $current_cart_id = $current_cart['id'] ?? $current_cart->id; $current_cart_session_id = $current_cart['session_id'] ?? $current_cart->session_id; } else { - //if someone deleted then take the flow to the normal + //if someone deleted handle flow to the normal. $this->repairCart($cart_session_id, $id); } - //matching the session id present in the cookie and database are same or not. + //Matching the session id present in the cookie and database are same or not. if((session()->get('cart_session_id') == Cookie::get('cart_session_id')) && ($current_cart_session_id == session()->get('cart_session_id'))) { + $current_cart_items = $this->cart->items($current_cart_id); + $current_cart_products = array(); - $current_cart_products = $this->cart->getProducts($current_cart_id); + foreach($current_cart_items as $current_cart_item) { + array_push($current_cart_products, $this->cartItem->getProduct($current_cart_item->id)); + } //checking new product coming in the cart is new or previously added item. foreach($current_cart_products as $key => $value) { - $product_id = $value['id'] ?? $value->id; + $product_id = $value; if($product_id == $id) { - //create status code to communicate with session flash + //create status code to communicate with session flash. + $cartItemId = $this->cartItem->findOneByField('product_id', $id)->id; + + $cartItemQuantity = $this->cartItem->findOneByField('product_id', $id)->quantity; + + $this->cartItem->update(['quantity' => $cartItemQuantity + $data['quantity']], $cartItemId); + session()->flash('error', 'Item Already In Cart'); - //remove this its temporary + //remove this its temporary. dump('Item Already In Cart'); return redirect()->back(); @@ -92,29 +100,27 @@ class Cart { } //cart data being attached to the instace. - $cart_data = $this->cart->attach($current_cart_id, $id, 1); + $cart_data = $this->cart->attach($current_cart_id, $id, $data['quantity']); - //getting the products after being attached to cart instance - $cart_products = $this->cart->getProducts($current_cart_id); + //getting the products after being attached to cart instance. + $cart_products = $this->cart->items($current_cart_id); //storing the information in session. session()->put('cart_data', [$current_cart, $cart_products]); session()->flash('Success', 'Item Added To Cart Successfully'); - dump($cart_products); - - //return the control to the controller + //return the control to the controller. return redirect()->back(); } else { - //repair the cart, will remake the session + //repair the cart, will remake the session. //and add the product in the new cart instance. $this->repairCart($cart_session_id, $id); } } else { //function call - $this->createNewCart($id); + $this->createNewCart($id, $data); } } @@ -128,11 +134,12 @@ class Cart { * @return mixed */ - public function createNewCart($id) { + public function createNewCart($id, $data) { $fresh_cart_session_id = session()->getId(); - $data['session_id'] = $fresh_cart_session_id; + if(!auth()->guard('customer')->check()) + $data['session_id'] = $fresh_cart_session_id; $data['channel_id'] = core()->getCurrentChannel()->id; @@ -144,10 +151,12 @@ class Cart { $cart_product['product_id'] = $id; - $cart_product['quantity'] = 1; + $cart_product['quantity'] = $data['quantity']; $cart_product['cart_id'] = $new_cart_id; + $cart_product['price'] = $new_cart_id; + if($cart_product = $this->cart->attach($new_cart_id, $cart_product['product_id'], $cart_product['quantity'])) { session()->put('cart_data', [$cart, $cart_product]); @@ -248,7 +257,7 @@ class Cart { of the logged in user. */ - public function add($id) { + public function add($id, $itemdata) { $products = array(); @@ -272,24 +281,32 @@ class Cart { * table. */ if(isset($customer_cart)) { - $customer_cart_products = $this->cart->getProducts($customer_cart_id); + $customer_cart_items = $this->cart->items($customer_cart_id); + + $customer_cart_products = array(); + + foreach($customer_cart_items as $customer_cart_item) { + array_push($customer_cart_products, $this->cartItem->getProduct($customer_cart_item->id)); + } if (isset($customer_cart_products)) { foreach ($customer_cart_products as $customer_cart_product) { - if($customer_cart_product->id == $id) { - dump('Item already exists in cart'); + if($customer_cart_product == $id) { + $cartItemId = $this->cartItem->findOneByField('product_id', $id)->id; + + $cartItemQuantity = $this->cartItem->findOneByField('product_id', $id)->quantity; + + $this->cartItem->update(['quantity' => $cartItemQuantity + $itemdata['quantity']], $cartItemId); session()->flash('error', 'Item already exists in cart'); return redirect()->back(); - - //maybe increase the quantity in here } } //add the product in the cart - $this->cart->attach($customer_cart_id, $id, 1); + $this->cart->attach($customer_cart_id, $id, $itemdata['quantity']); session()->flash('success', 'Item Added To Cart Successfully'); @@ -315,7 +332,7 @@ class Cart { if($new_cart = $this->cart->create($data)) { $new_cart_id = $new_cart->id ?? $new_cart['id']; - $this->cart->attach($new_cart_id, $id, 1); + $this->cart->attach($new_cart_id, $id, $itemdata['quantity']); session()->flash('success', 'Item Added To Cart Successfully'); @@ -370,46 +387,60 @@ class Cart { $guest_cart = $this->cart->findOneByField('session_id', $cart_session_id); if(!isset($guest_cart)) { - dd('Some One Deleted Cart or it wasn\'t there from the start'); + dd('Some One Deleted Cart'); return redirect()->back(); } + $guest_cart_items = $this->cart->items($guest_cart->id); - $guest_cart_products = $this->cart->getProducts($guest_cart->id); + $guest_cart_products = array(); + + foreach($guest_cart_items as $guest_cart_item) { + array_push($guest_cart_products, $this->cartItem->getProduct($guest_cart_item->id)); + } //check if the current logged in customer is also //having any previously saved cart instances. $customer_cart = $this->cart->findOneByField('customer_id', $customer_id); if(isset($customer_cart)) { - $customer_cart_products = $this->cart->getProducts($customer_cart->id); + $customer_cart_items = $this->cart->items($customer_cart->id); + + $customer_cart_products = array(); + + foreach($customer_cart_items as $customer_cart_item) { + array_push($customer_cart_products, $this->cartItem->getProduct($customer_cart_item->id)); + } foreach($guest_cart_products as $key => $guest_cart_product) { - foreach($customer_cart_products as $customer_cart_product) { + if($guest_cart_product == $customer_cart_product) { + $cartItemId = $this->cartItem->findWhere(['cart_id'=> $guest_cart->id, 'product_id' => $guest_cart_product])[0]->id; - if($guest_cart_product->id == $customer_cart_product->id) { + $cartItemQuantity = $this->cartItem->findWhere(['cart_id'=> $guest_cart->id, 'product_id' => $guest_cart_product])[0]->quantity; - $quantity = $guest_cart_product->toArray()['pivot']['quantity'] + 1; + $customerItemId = $this->cartItem->findWhere(['cart_id'=> $customer_cart->id, 'product_id' => $customer_cart_product])[0]->id; - $pivot = $guest_cart_product->toArray()['pivot']; + $customerItemQuantity = $this->cartItem->findWhere(['cart_id'=> $customer_cart->id, 'product_id' => $customer_cart_product])[0]->quantity; - $saveQuantity = $this->cart->updateRelatedForMerge($pivot, 'quantity', $quantity); + $this->cartItem->delete($cartItemId); + + $this->cartItem->update(['quantity' => $cartItemQuantity + $customerItemQuantity], $customerItemId); unset($guest_cart_products[$key]); } } } - //insert the new products here. foreach ($guest_cart_products as $key => $guest_cart_product) { - $product = $guest_cart_product->toArray(); + // dd($this->cartItem->findWhere(['cart_id'=> $guest_cart->id, 'product_id' => $guest_cart_product])[0]); + $cartItemId = $this->cartItem->findWhere(['cart_id'=> $guest_cart->id, 'product_id' => $guest_cart_product])[0]->id; - $this->cart->updateRelatedForMerge($product['pivot'], 'cart_id', $customer_cart->id); + $this->cartItem->update(['cart_id' => $customer_cart->id], $cartItemId); } //detach with guest cart records - $this->cart->detachAndDeleteParent($guest_cart->id); + $this->cart->deleteParent($guest_cart->id); Cookie::queue(Cookie::forget('cart_session_id')); diff --git a/packages/Webkul/Cart/src/Database/migrations/2018_09_05_150915_create_cart_products_table.php b/packages/Webkul/Cart/src/Database/migrations/2018_09_05_150915_create_cart_items_table.php similarity index 93% rename from packages/Webkul/Cart/src/Database/migrations/2018_09_05_150915_create_cart_products_table.php rename to packages/Webkul/Cart/src/Database/migrations/2018_09_05_150915_create_cart_items_table.php index 5d3f4b2ce..0ab6260f7 100644 --- a/packages/Webkul/Cart/src/Database/migrations/2018_09_05_150915_create_cart_products_table.php +++ b/packages/Webkul/Cart/src/Database/migrations/2018_09_05_150915_create_cart_items_table.php @@ -13,7 +13,7 @@ class CreateCartProductsTable extends Migration */ public function up() { - Schema::create('cart_products', function (Blueprint $table) { + Schema::create('cart_items', function (Blueprint $table) { $table->increments('id'); $table->integer('product_id')->unsigned(); $table->foreign('product_id')->references('id')->on('products'); diff --git a/packages/Webkul/Cart/src/Http/Controllers/CartController.php b/packages/Webkul/Cart/src/Http/Controllers/CartController.php index 101d28b9a..fd6f1d5fe 100644 --- a/packages/Webkul/Cart/src/Http/Controllers/CartController.php +++ b/packages/Webkul/Cart/src/Http/Controllers/CartController.php @@ -7,7 +7,7 @@ use Illuminate\Http\Response; //Cart repositories use Webkul\Cart\Repositories\CartRepository; -use Webkul\Cart\Repositories\CartProductRepository; +use Webkul\Cart\Repositories\CartItemRepository; //Customer repositories use Webkul\Customer\Repositories\CustomerRepository; @@ -36,11 +36,11 @@ class CartController extends Controller protected $cart; - protected $cartProduct; + protected $cartItem; protected $customer; - public function __construct(CartRepository $cart, CartProductRepository $cartProduct, CustomerRepository $customer) { + public function __construct(CartRepository $cart, CartItemRepository $cartItem, CustomerRepository $customer) { $this->middleware('customer')->except(['add', 'remove', 'test']); @@ -48,7 +48,7 @@ class CartController extends Controller $this->cart = $cart; - $this->cartProduct = $cartProduct; + $this->cartItem = $cartItem; } /** @@ -60,11 +60,11 @@ class CartController extends Controller */ public function add($id) { - + $data = request()->input(); if(auth()->guard('customer')->check()) { - Cart::add($id); + Cart::add($id, $data); } else { - Cart::guestUnitAdd($id); + Cart::guestUnitAdd($id, $data); } return redirect()->back(); @@ -81,20 +81,26 @@ class CartController extends Controller return redirect()->back(); } - // public function test() { - // $cookie = Cookie::get('cart_session_id'); + /** + * This is a test for + * relationship existence + * from cart item to product + * + * @return Array + */ + public function test() { + $cartItems = $this->cart->items(75); - // $cart = $this->cart->findOneByField('session_id', $cookie); + $products = array(); + foreach($cartItems as $cartItem) { + $cartItemId = $cartItem->id; - // $cart_products = $this->cart->getProducts($cart->id); + $this->cart->updateItem(75, $cartItemId, 'quantity', $cartItem->quantity+1); - // foreach($cart_products as $cart_product) { - // $quantity = $cart_product->toArray()['pivot']['quantity'] + 1; + array_push($products, ['product_id' => $this->cartItem->getProduct($cartItemId), 'quantity' => $cartItem->quantity]); + } - // $pivot = $cart_product->toArray()['pivot']; - - // $saveQuantity = $this->cart->saveRelated($pivot, 'quantity', $quantity+1); - // } - // dd('done'); - // } + dd($products); + return response()->json($products, 200); + } } \ No newline at end of file diff --git a/packages/Webkul/Cart/src/Http/ViewComposers/CartComposer.php b/packages/Webkul/Cart/src/Http/ViewComposers/CartComposer.php index a216c1d5c..10f3d799d 100644 --- a/packages/Webkul/Cart/src/Http/ViewComposers/CartComposer.php +++ b/packages/Webkul/Cart/src/Http/ViewComposers/CartComposer.php @@ -7,6 +7,8 @@ use Illuminate\Support\Collection; use Webkul\Cart\Repositories\CartRepository; +use Webkul\Cart\Repositories\CartItemRepository; + use Cookie; use Cart; /** @@ -32,27 +34,42 @@ class CartComposer * @param View $view * @return void */ - public function __construct(CartRepository $cart) { + public function __construct(CartRepository $cart, CartItemRepository $cartItem) { $this->cart = $cart; + + $this->cartItem = $cartItem; } public function compose(View $view) { if(auth()->guard('customer')->check()) { $cart = $this->cart->findOneByField('customer_id', auth()->guard('customer')->user()->id); - $cart_products = $this->cart->getProducts($cart['id']); + if(isset($cart)) { + $cart_items = $this->cart->items($cart['id']); - // dd($cart_products); + $cart_products = array(); - $view->with('cart', $cart_products); + foreach($cart_items as $cart_item) { + array_push($cart_products, $this->cartItem->getProduct($cart_item->id)); + } + $view->with('cart', $cart_products); + } } else { if(Cookie::has('cart_session_id')) { $cart = $this->cart->findOneByField('session_id', Cookie::get('cart_session_id')); - $cart_products = $this->cart->getProducts($cart['id']); + if(isset($cart)) { + $cart_items = $this->cart->items($cart['id']); - $view->with('cart', $cart_products); + $cart_products = array(); + + foreach($cart_items as $cart_item) { + array_push($cart_products, $this->cartItem->getProduct($cart_item->id)); + } + + $view->with('cart', $cart_products); + } } } } diff --git a/packages/Webkul/Cart/src/Models/Cart.php b/packages/Webkul/Cart/src/Models/Cart.php index f1591cdb4..ff076ad79 100644 --- a/packages/Webkul/Cart/src/Models/Cart.php +++ b/packages/Webkul/Cart/src/Models/Cart.php @@ -16,6 +16,10 @@ class Cart extends Model public function with_products() { - return $this->belongsToMany(Product::class, 'cart_products')->withPivot('id', 'product_id','quantity', 'cart_id'); + return $this->belongsToMany(Product::class, 'cart_items')->withPivot('id', 'product_id','quantity', 'cart_id'); + } + + public function items() { + return $this->hasMany('Webkul\Cart\Models\CartItem'); } } diff --git a/packages/Webkul/Cart/src/Models/CartItem.php b/packages/Webkul/Cart/src/Models/CartItem.php new file mode 100644 index 000000000..d864ae6f8 --- /dev/null +++ b/packages/Webkul/Cart/src/Models/CartItem.php @@ -0,0 +1,17 @@ +hasOne('Webkul\Product\Models\Product', 'id', 'product_id'); + } +} diff --git a/packages/Webkul/Cart/src/Models/CartProduct.php b/packages/Webkul/Cart/src/Models/CartProduct.php deleted file mode 100644 index 8b8a9d32b..000000000 --- a/packages/Webkul/Cart/src/Models/CartProduct.php +++ /dev/null @@ -1,11 +0,0 @@ -alias('cart', CartFacade::class); + + $loader->alias('cart', Cart::class); $this->app->singleton('cart', function () { - return new Cart(); + return new cart(); }); + + $this->app->bind('cart', 'Webkul\Cart\Cart'); } -} +} \ No newline at end of file diff --git a/packages/Webkul/Cart/src/Repositories/CartProductRepository.php b/packages/Webkul/Cart/src/Repositories/CartItemRepository.php similarity index 80% rename from packages/Webkul/Cart/src/Repositories/CartProductRepository.php rename to packages/Webkul/Cart/src/Repositories/CartItemRepository.php index 0c3636d5d..78f2e615d 100644 --- a/packages/Webkul/Cart/src/Repositories/CartProductRepository.php +++ b/packages/Webkul/Cart/src/Repositories/CartItemRepository.php @@ -11,7 +11,7 @@ use Webkul\Core\Eloquent\Repository; * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class CartProductRepository extends Repository +class CartItemRepository extends Repository { /** * Specify Model class name @@ -21,7 +21,7 @@ class CartProductRepository extends Repository function model() { - return 'Webkul\Cart\Models\CartProduct'; + return 'Webkul\Cart\Models\CartItem'; } /** @@ -51,4 +51,8 @@ class CartProductRepository extends Repository return $cartitems; } + + public function getProduct($cartItemId) { + return $this->model->find($cartItemId)->product->id; + } } \ No newline at end of file diff --git a/packages/Webkul/Cart/src/Repositories/CartRepository.php b/packages/Webkul/Cart/src/Repositories/CartRepository.php index e7f951abd..cca574045 100644 --- a/packages/Webkul/Cart/src/Repositories/CartRepository.php +++ b/packages/Webkul/Cart/src/Repositories/CartRepository.php @@ -77,12 +77,25 @@ class CartRepository extends Repository * * @return Mixed */ - public function updateRelatedForMerge($pivot, $column, $value) { - $cart_product = $this->model->findOrFail($pivot['cart_id']); + public function updateRelatedForMerge($cart_id, $product_id, $column, $value) { + $cart_product = $this->model->findOrFail($cart_id); - return $cart_product->with_products()->updateExistingPivot($pivot['product_id'], array($column => $value)); + return $cart_product->with_products()->updateExistingPivot($product_id, array($column => $value)); } + /** + * Update the quantity of + * previously added item + * in the cart. + * + * @return Mixed + */ + + // public function updateRelatedInItems($cartId, $cartItemId, $column, $value) { + + // return $this->updateItem($cartId)->syncWithoutDetaching($cartItemId, [$column => $value]); + // } + /** * Method to detach * associations. @@ -92,12 +105,13 @@ class CartRepository extends Repository * * @return Mixed */ - public function detachAndDeleteParent($cart_id) { + public function deleteParent($cart_id) { $cart = $this->model->find($cart_id); - //apply strict check for verifying guest ownership on this record. - $cart->with_products()->detach(); - return $this->model->destroy($cart_id); } + + public function items($cartId) { + return $this->model->find($cartId)->items; + } } \ No newline at end of file diff --git a/packages/Webkul/Core/src/Core.php b/packages/Webkul/Core/src/Core.php index 0b5d36e49..119d43b41 100644 --- a/packages/Webkul/Core/src/Core.php +++ b/packages/Webkul/Core/src/Core.php @@ -140,8 +140,8 @@ class Core $channel = $this->getCurrentChannel(); - $currencyCode = $channel->base_currency->code; - // $currencyCode = $channel->base_currency; + // $currencyCode = $channel->base_currency->code; + $currencyCode = $channel->base_currency; return currency($price, $currencyCode); } diff --git a/packages/Webkul/Product/src/Contracts/Criteria/AttributeToSelectCriteria.php b/packages/Webkul/Product/src/Contracts/Criteria/AttributeToSelectCriteria.php index cc86260e7..4f5a47cff 100644 --- a/packages/Webkul/Product/src/Contracts/Criteria/AttributeToSelectCriteria.php +++ b/packages/Webkul/Product/src/Contracts/Criteria/AttributeToSelectCriteria.php @@ -59,13 +59,13 @@ class AttributeToSelectCriteria extends AbstractProduct implements CriteriaInter public function apply($model, RepositoryInterface $repository) { $model = $model->select('products.*'); - + foreach ($this->attributeToSelect as $code) { $attribute = $this->attribute->findOneByField('code', $code); if(!$attribute) continue; - + $productValueAlias = 'pav_' . $attribute->code; $model = $model->leftJoin('product_attribute_values as ' . $productValueAlias, function($qb) use($attribute, $productValueAlias) { diff --git a/packages/Webkul/Product/src/Models/ProductAttributeValue.php b/packages/Webkul/Product/src/Models/ProductAttributeValue.php index 828664442..6eb459ae3 100644 --- a/packages/Webkul/Product/src/Models/ProductAttributeValue.php +++ b/packages/Webkul/Product/src/Models/ProductAttributeValue.php @@ -23,7 +23,7 @@ class ProductAttributeValue extends Model 'boolean' => 'boolean_value', 'select' => 'integer_value', 'multiselect' => 'text_value', - 'datetime' => 'datetime_time', + 'datetime' => 'datetime_value', 'date' => 'date_value', ]; diff --git a/packages/Webkul/Shop/src/Http/routes.php b/packages/Webkul/Shop/src/Http/routes.php index 7d8361989..6e00de737 100644 --- a/packages/Webkul/Shop/src/Http/routes.php +++ b/packages/Webkul/Shop/src/Http/routes.php @@ -14,8 +14,7 @@ Route::group(['middleware' => ['web']], function () { 'view' => 'shop::checkout.onepage' ])->name('shop.checkout'); - /* dummy routes ends here */ - + Route::get('test', 'Webkul\Cart\Http\Controllers\CartController@test'); Route::get('/products/{slug}', 'Webkul\Shop\Http\Controllers\ProductController@index')->defaults('_config', [ 'view' => 'shop::products.view' diff --git a/packages/Webkul/Shop/src/Resources/assets/js/components/cart-dropdown.vue b/packages/Webkul/Shop/src/Resources/assets/js/components/cart-dropdown.vue index 9b27c8634..570197b9d 100644 --- a/packages/Webkul/Shop/src/Resources/assets/js/components/cart-dropdown.vue +++ b/packages/Webkul/Shop/src/Resources/assets/js/components/cart-dropdown.vue @@ -75,6 +75,8 @@ export default { initializeDropdown: function() { this.totalitems = this.items.length; + this.cart_items = this.items; + console.log("The cart items here are = ",cart_items); } } } diff --git a/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php b/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php index 0fdee9e33..72fa0b8da 100644 --- a/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php @@ -91,7 +91,19 @@ - + @if(isset($cart)) + + @else + + @endif {{-- Meant for responsive views only --}}