From 84a687239d62291445f43633c2f81081c6480f79 Mon Sep 17 00:00:00 2001 From: prashant-webkul Date: Thu, 13 Sep 2018 19:10:01 +0530 Subject: [PATCH 1/6] Do not take this pull very reactive --- packages/Webkul/Cart/src/Cart.php | 39 +++++++++++++++++-------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/packages/Webkul/Cart/src/Cart.php b/packages/Webkul/Cart/src/Cart.php index 0d9342e41..6c2306843 100644 --- a/packages/Webkul/Cart/src/Cart.php +++ b/packages/Webkul/Cart/src/Cart.php @@ -51,9 +51,9 @@ class Cart { $cart_session_id = Cookie::get('cart_session_id'); - $cart = $this->cart->getOneByField('session_id'. $cart_session_id); + $cart = $this->cart->getOneByField('session_id', $cart_session_id); - $cartId = $cart->id ?? $cart['id'] ; + $cartId = $cart->id ?? $cart['id']; $products = $this->getProducts($id); @@ -67,6 +67,7 @@ class Cart { if($this->cartProduct->create($id)) { session()->flash('Success', 'Product Added To Cart'); + return redirect()->back(); } return redirect()->back(); @@ -287,14 +288,14 @@ class Cart { */ public function handleMerge() { - // $productsInCookie = unserialize(Cookie::get('session_c')); - $cart_session_id = Cookie::get('cart_session_id'); - $cart = $this->cart->findOneByField('session_id'); + $cart = $this->cart->findOneByField('session_id', $cart_session_id); $cartId = $cart->id ?? $cart['id']; + $currentCartProducts = $this->cart->getProducts($cartId); + $data['customer_id'] = auth()->guard('customer')->user()->id; $data['channel_id'] = core()->getCurrentChannel()->id; @@ -311,39 +312,43 @@ class Cart { foreach($customerCartProducts as $previousCartProduct) { - foreach($productsInCookie as $key => $productInCookie) { + foreach($currentCartProducts as $key => $currentCartProduct) { - if($previousCartProduct->id == $productInCookie) { + if($previousCartProduct->id == $currentCartProduct) { - unset($productsInCookie[$key]); + unset($currentCartProducts[$key]); } } } } - /*if the above block executes it will remove duplicates - else product in cookies will be stored in the database.*/ + /* + if the above block executes it will remove duplicates + else product in cookies will be stored in the database. + */ + $this->cart->findOneByField('session_id', $cart_session_id)->update($data['customer_id']); - foreach($productsInCookie as $key => $cookieProduct) { + foreach($currentCartProducts as $key => $currentCartProduct) { - $product['product_id'] = $cookieProduct; + $product['product_id'] = $currentCartProduct; - $product['quantity'] = 1; + $product['quantity'] = 1; //initialize the qty from the params passed from post $product['cart_id'] = $customerCartId; $this->cartProduct->create($product); } - //forget that cookie here. - Cookie::queue(Cookie::forget('session_c')); + //forget the cart cookie that holds the cart session id + Cookie::queue(Cookie::forget('cart_session_id')); + return redirect()->back(); } else { if($cart = $this->cart->create($data)) { - foreach($productsInCookie as $productInCookie) { + foreach($currentCartProducts as $currentCartProduct) { - $product['product_id'] = $cookieProduct; + $product['product_id'] = $currentCartProduct; $product['quantity'] = 1; From 9cea4133f75907498b9c0a8a6c91151b072f4533 Mon Sep 17 00:00:00 2001 From: prashant-webkul Date: Fri, 14 Sep 2018 18:45:49 +0530 Subject: [PATCH 2/6] Case of Cart Merging Left --- app/Providers/AppServiceProvider.php | 2 - config/database.php | 2 +- packages/Webkul/Cart/src/Cart.php | 384 ++++++++++-------- .../src/Http/Controllers/CartController.php | 4 + .../Cart/src/Repositories/CartRepository.php | 23 +- .../Http/Listeners/CustomerEventsHandler.php | 2 +- .../Shop/src/Resources/assets/sass/app.scss | 42 +- public/themes/default/assets/css/shop.css | 46 +-- public/themes/default/assets/js/shop.js | 4 +- .../themes/default/assets/mix-manifest.json | 2 +- 10 files changed, 257 insertions(+), 254 deletions(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 706c00313..64e2c2f45 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -3,7 +3,6 @@ namespace App\Providers; use Illuminate\Support\ServiceProvider; -use Illuminate\Support\Facades\Schema; class AppServiceProvider extends ServiceProvider { @@ -14,7 +13,6 @@ class AppServiceProvider extends ServiceProvider */ public function boot() { - Schema::defaultStringLength(191); } /** diff --git a/config/database.php b/config/database.php index cab5d068f..e486bd20d 100644 --- a/config/database.php +++ b/config/database.php @@ -51,7 +51,7 @@ return [ 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'strict' => true, - 'engine' => null, + 'engine' => 'InnoDB ROW_FORMAT=DYNAMIC', ], 'pgsql' => [ diff --git a/packages/Webkul/Cart/src/Cart.php b/packages/Webkul/Cart/src/Cart.php index 6c2306843..322c571ea 100644 --- a/packages/Webkul/Cart/src/Cart.php +++ b/packages/Webkul/Cart/src/Cart.php @@ -47,43 +47,152 @@ class Cart { $minutes = 10; - if(Cookie::get('current_session_id')) { + if(Cookie::has('cart_session_id')) { $cart_session_id = Cookie::get('cart_session_id'); - $cart = $this->cart->getOneByField('session_id', $cart_session_id); + $current_cart = $this->cart->findOneByField('session_id', $cart_session_id); - $cartId = $cart->id ?? $cart['id']; + // dd('Cookie = ',$cart_session_id, 'Session = ', session()->get('cart_session_id'), 'DB = ', $current_cart->session_id); - $products = $this->getProducts($id); + if(isset($current_cart)) { + $current_cart_id = $current_cart['id'] ?? $current_cart->id; - foreach($products as $key => $value) { - if($value == $id) { - dd('product already in the cart'); - - return redirect()->back(); - } + $current_cart_session_id = $current_cart['session_id'] ?? $current_cart->session_id; + } else { + $this->repairCart($cart_session_id, $id); } - if($this->cartProduct->create($id)) { - session()->flash('Success', 'Product Added To Cart'); + + if((session()->get('cart_session_id') == Cookie::get('cart_session_id')) && ($current_cart_session_id == session()->get('cart_session_id'))) { + $current_cart_products = array(); + + $current_cart_products = $this->cart->getProducts($current_cart_id); + + foreach($current_cart_products as $key => $value) { + + $product_id = $value['id'] ?? $value->id; + + if($product_id == $id) { + session()->flash('error', 'Item Already In Cart'); + + dump('Item Already In Cart'); + + return redirect()->back(); + } + } + + $cart_data = $this->cart->attach($current_cart_id, $id, 1); + + $cart_products = $this->cart->getProducts($current_cart_id); + + session()->put('cart_data', [$current_cart, $cart_products]); + + session()->flash('Success', 'Item Added In Cart'); + + dump($cart_products); + + return redirect()->back(); + + } else { + // throw new \Exception('Error, Many or Few Session discrepancies found.'); + + $this->repairCart($cart_session_id, $id); + } + } else { + $this->createNewCart($id); + } + } + + /*helpers*/ + public function makeCartSession($to_process) { + session()->put('cart_session_id', $to_process); + + return session()->get('cart_session_id'); + } + + /** + * Create New Cart + * Cart, Cookie & + * Session. + * + * @return mixed + */ + + public function createNewCart($id) { + $minutes = 120; + + $fresh_cart_session_id = session()->getId(); + + Cookie::queue('cart_session_id', $fresh_cart_session_id, $minutes); + + $cart_session_id = $this->makeCartSession($fresh_cart_session_id); + + $data['session_id'] = $fresh_cart_session_id; + + $data['channel_id'] = core()->getCurrentChannel()->id; + + if($cart = $this->cart->create($data)) { + + $new_cart_id = $cart->id ?? $cart['id']; + + $cart_product['product_id'] = $id; + + $cart_product['quantity'] = 1; + + $cart_product['cart_id'] = $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]); + + session()->flash('success', 'Product Added To Cart'); return redirect()->back(); } - return redirect()->back(); + } + session()->flash('error', 'Some Error Occured'); - } else { - Cookie::queue('cart_session_id', session()->id(), $minutes); + return redirect()->back(); + } - $data['session_id'] = Cookie::get('cart_session_id'); + /** + * Reset Session and + * Cookie values + * and sync database + * if present. + * + * @return mixed + */ + + public function repairCart($cart_session_id, $product_id) { + + if($cart_session_id == session()->get('cart_session_id')) { + $data['session_id'] = $cart_session_id; $data['channel_id'] = core()->getCurrentChannel()->id; - if($this->cart->create($data)) { - if($this->cartProduct->create($product)) { - session()->flash('Success', 'Product Added To Cart'); - } - } + $cart = $this->cart->create($data); + + $cart_id = $cart['id'] ?? $cart->id; + + $this->cart->attach($cart_id, $product_id, 1); + + session()->flash('success', 'Product Added In Cart'); + + return redirect()->back(); + + } else { + + Cookie::queue(Cookie::forget('cart_session_id')); + + session()->forget('cart_session_id'); + + session()->regenerate(); + + session()->flash('error', 'Please Try Adding Product Again.'); + + return redirect()->back(); } } @@ -165,108 +274,6 @@ class Cart { return redirect()->back(); } - // } - - // //case when cookie has products and customer also have data in cart tables - // if(isset($customerCart) && isset($cartCookie)) { - // //for unsetting the cookie for the cart uncomment after all done - // // Cookie::queue(Cookie::forget('session_c')); - - // //check if there is any repetition in the products - // $customerCartId = $customerCart->id ?? $customerCart['id']; - - // //to check if the customer is also having some products saved in the pivot - // //for the products. - // $customerCartProducts = $this->cart->getProducts($customerCartId); - - // //if there are products already in cart of that customer - // if(isset($customerCartProducts)) { - - // foreach($customerCartProducts as $previousCartProduct) { - - // dump($customerCartProducts); - - // foreach($cookieProducts as $key => $cookieProduct) { - - // if($previousCartProduct->id == $cookieProduct) { - - // unset($cookieProducts[$key]); - // } - // } - // } - // } - - // /*if the above block executes it will remove duplicates - // else product in cookies will be stored in the database.*/ - - // foreach($cookieProducts as $key => $cookieProduct) { - - // $product['product_id'] = $cookieProduct; - - // $product['quantity'] = 1; - - // $product['cart_id'] = $customerCartId; - - // $this->cartProduct->create($product); - // } - - // dump('Products in the cart synced.'); - - // return redirect()->back(); - - // } else if(isset($customerCart) && !isset($cartCookie)) { - // //case when there is no data in guest's cart - - // $customerCartId = $customerCart->id ?? $customerCart['id']; - - // $customerCartProducts = $this->cart->getProducts($customerCartId); - - // foreach($customerCartProducts as $previousCartProduct) { - - // if($previousCartProduct->id == $id) { - - // dd('product already in the cart::AUTH'); - - // return redirect()->back(); - // } - // } - // $product['product_id'] = $id; - - // $product['quantity'] = 1; - - // $product['cart_id'] = $customerCartId; - - // $this->cartProduct->create($product); - - // dump('new item added in the cart'); - - // return redirect()->back(); - - // } else if(!isset($customerCart) && isset($cartCookie)) { - - // $products = unserialize(Cookie::get('session_c')); - - // if ($cart = $this->cart->create($data)) { - - // foreach($products as $product) { - - // $product['product_id'] = $id; - - // $product['quantity'] = 1; - - // $product['cart_id'] = $cart; - - // $this->cartProduct->create($product); - // } - // return redirect()->back(); - - // } else { - // session()->flash('error', 'Cannot Add Your Items To Cart'); - - // return redirect()->back(); - // } - // } - // } } /** @@ -286,79 +293,104 @@ class Cart { * with the existing data of cart * in the cart tables; */ - public function handleMerge() { + public function mergeCart() { - $cart_session_id = Cookie::get('cart_session_id'); + if(Cookie::has('cart_session_id')) { - $cart = $this->cart->findOneByField('session_id', $cart_session_id); + $cart_session_id = Cookie::get('cart_session_id'); - $cartId = $cart->id ?? $cart['id']; + $current_cart = $this->cart->findOneByField('session_id', $cart_session_id); - $currentCartProducts = $this->cart->getProducts($cartId); + //it is impossible to not have an entry in cart table and cart_products. + //will later handle the exceoption. + $current_cart_id = $current_cart['id'] ?? $current_cart->id; - $data['customer_id'] = auth()->guard('customer')->user()->id; + $current_cart_session_id = $current_cart['session_id'] ?? $current_cart->session_id; - $data['channel_id'] = core()->getCurrentChannel()->id; + $current_cart_products = $this->cart->getProducts($current_cart_id); - $customerCart = $this->cart->findOneByField('customer_id', $data['customer_id']); + $customer_id = auth()->guard('customer')->user()->id; //working - if(isset($customerCart)) { + if($cart_session_id == $current_cart_session_id) { + $current_cart_products = array(); - $customerCartId = $customerCart->id ?? $customerCart['id']; + $customer_cart = $this->cart->findByField(['customer_id'=> $customer_id]); - $customerCartProducts = $this->cart->getProducts($customerCartId); + //check previous saved cart of customer. + if(!$customer_cart->isEmpty()) { - if(isset($customerCartProducts)) { + $customer_cart_id = $customer_cart->id; - foreach($customerCartProducts as $previousCartProduct) { + $customer_cart_products = $this->cart->getProducts($customer_cart_id); - foreach($currentCartProducts as $key => $currentCartProduct) { + foreach($current_cart_products as $key => $value) { - if($previousCartProduct->id == $currentCartProduct) { + $product_id = $value['id'] ?? $value->id; - unset($currentCartProducts[$key]); + foreach($current_cart_products as $key => $current_cart_product) { + + $current_product_id = $current_cart_product['id'] ?? $current_cart_product->id; + + if($current_product_id == $product_id) { + + unset($current_cart_products[$key]); + } } } + + + foreach($current_cart_products as $current_cart_product) { + + $current_cart_product_id = $current_cart_product['id'] ?? $current_cart_product->id; + + $this->cart->attach($current_cart_id, $current_cart_product_id, 1); + } + + $this->cart->update(['customer_id' => $customer_id], $current_cart_id); + + $customer_cart = $this->cart->findOneByField('customer_id', $customer_id); + + $customer_cart_id = $customer_cart->id; + + if($this->cart->getProducts($customer_cart_id) && isset($current_cart_products)) { + foreach($current_cart_products as $key => $value) { + + array_push($cart_products, $current_cart_product); + } + } + + session()->put('cart_data', [$customer_cart, $cart_products]); + + session()->flash('Success', 'Item Added In Cart'); + + dump($cart_products); + + return redirect()->back(); + } else { + + $session_id = session()->getId(); + + $customer_id = auth()->guard('customer')->user()->id; + + $updated_cart = $this->cart->update(['customer_id' => $customer_id, 'session_id' => $session_id], $current_cart_id); + + $updated_cart_products = $this->cart->getProducts($updated_cart->id); + + Cookie::queue('cart_session_id', $session_id, 120); + + session()->put('cart_session_id', $session_id); + + session('cart_data', [$updated_cart, $updated_cart_products]); + + return redirect()->back(); } + } else { + throw new \Exception('Error, Session discrepancies found.'); + + $this->repairCart($cart_session_id, $id); } - - /* - if the above block executes it will remove duplicates - else product in cookies will be stored in the database. - */ - $this->cart->findOneByField('session_id', $cart_session_id)->update($data['customer_id']); - - foreach($currentCartProducts as $key => $currentCartProduct) { - - $product['product_id'] = $currentCartProduct; - - $product['quantity'] = 1; //initialize the qty from the params passed from post - - $product['cart_id'] = $customerCartId; - - $this->cartProduct->create($product); - } - - //forget the cart cookie that holds the cart session id - Cookie::queue(Cookie::forget('cart_session_id')); - return redirect()->back(); } else { - - if($cart = $this->cart->create($data)) { - - foreach($currentCartProducts as $currentCartProduct) { - - $product['product_id'] = $currentCartProduct; - - $product['quantity'] = 1; - - $product['cart_id'] = $cart->id; - - $this->cartProduct->create($product); - } - } - //forget the Cookie - Cookie::queue(Cookie::forget('session_c')); + throw new \Exception('Nothing found'); return redirect()->back(); } diff --git a/packages/Webkul/Cart/src/Http/Controllers/CartController.php b/packages/Webkul/Cart/src/Http/Controllers/CartController.php index cbb144943..972719384 100644 --- a/packages/Webkul/Cart/src/Http/Controllers/CartController.php +++ b/packages/Webkul/Cart/src/Http/Controllers/CartController.php @@ -66,6 +66,8 @@ class CartController extends Controller } else { Cart::guestUnitAdd($id); } + + return redirect()->back(); } public function remove($id) { @@ -75,5 +77,7 @@ class CartController extends Controller } else { Cart::guestUnitRemove($id); } + + return redirect()->back(); } } \ 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 d75299717..0ba0e4b07 100644 --- a/packages/Webkul/Cart/src/Repositories/CartRepository.php +++ b/packages/Webkul/Cart/src/Repositories/CartRepository.php @@ -61,29 +61,18 @@ class CartRepository extends Repository * Method to attach * associations * - * @return mixed + * @return Eloquent */ - // public function onlyAttach($id, $taxRates) { + public function attach($cart_id, $product_id, $quantity) { - // foreach($taxRates as $key => $value) { - - // $this->model->findOrFail($id)->tax_rates()->attach($id, ['tax_category_id' => $id, 'tax_rate_id' => $value]); - // } - // } + $this->model->findOrFail($cart_id)->with_products()->attach($cart_id, ['product_id' => $product_id, 'cart_id' => $cart_id, 'quantity' => $quantity]); + } /** * Method to detach - * and attach the * associations * - * @return mixed - */ - // public function syncAndDetach($id, $taxRates) { - // $this->model->findOrFail($id)->tax_rates()->detach(); - - // foreach($taxRates as $key => $value) { - // $this->model->findOrFail($id)->tax_rates()->attach($id, ['tax_category_id' => $id, 'tax_rate_id' => $value]); - // } - // } + * @return Eloquent + */ } \ No newline at end of file diff --git a/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php b/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php index d4b4e26b1..c14b422d2 100644 --- a/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php +++ b/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php @@ -27,7 +27,7 @@ class CustomerEventsHandler { * check emptiness and then * do the appropriate actions. */ - Cart::handleMerge(); + Cart::mergeCart(); } /** diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss index 40c9b97e0..575420e13 100644 --- a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss +++ b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss @@ -8,6 +8,8 @@ body { margin: 0; padding: 0; font-weight: 500; + max-width: 100%; + width: auto; color: $font-color; font-size: $font-size-base; } @@ -23,8 +25,8 @@ body { .header-top { margin-bottom: 16px; display: flex; - max-width: 80%; - width: 100%; + max-width: 100%; + width: auto; margin-left: auto; margin-right: auto; align-items: center; @@ -187,7 +189,8 @@ body { display: block; font-size:16px; height: 48px; - width: 80%; + max-width: 100%; + width: auto; margin-left: auto; margin-right: auto; } @@ -610,10 +613,11 @@ body { section.slider-block { display: block; + margin-left: auto; + margin-right: auto; margin-bottom: 5%; div.slider-content { - width: 80%; height: 500px; margin-left: auto; margin-right: auto; @@ -763,54 +767,42 @@ section.slider-block { .main-container-wrapper { - margin-left: 10%; - margin-right: 10%; + max-width: 80%; + width: auto; + margin-left: auto; + margin-right: auto; .content-container { display: inline-block; width: 100%; } - .main { - display: inline-block; - width: 75% - } - .product-grid { display: grid; grid-gap: 30px; &.max-2-col { - grid-template-columns: repeat(2, minmax(250px, 1fr)); + grid-template-columns: repeat(2, minmax(auto, 1fr)); } &.max-3-col { - grid-template-columns: repeat(3, minmax(250px, 1fr)); + grid-template-columns: repeat(3, minmax(auto, 1fr)); } &.max-4-col { - grid-template-columns: repeat(4, minmax(250px, 1fr)); - } - - .product-card { - display: flex; - flex-flow: column; - justify-content: center; + grid-template-columns: repeat(4, minmax(auto, 1fr)); } } .product-card { .product-image { - background: #F2F2F2; margin-bottom: 10px; - // width: 380px; - // max-width: 100%; - // text-align: center; img { align-self: center; - width: 100%; + max-width: 100%; + width: auto; margin-bottom: 14px; } } diff --git a/public/themes/default/assets/css/shop.css b/public/themes/default/assets/css/shop.css index 9e29cbb81..064cd197d 100644 --- a/public/themes/default/assets/css/shop.css +++ b/public/themes/default/assets/css/shop.css @@ -27,6 +27,8 @@ body { margin: 0; padding: 0; font-weight: 500; + max-width: 100%; + width: auto; color: #242424; font-size: 16px; } @@ -45,8 +47,8 @@ body { display: -webkit-box; display: -ms-flexbox; display: flex; - max-width: 80%; - width: 100%; + max-width: 100%; + width: auto; margin-left: auto; margin-right: auto; -webkit-box-align: center; @@ -260,7 +262,8 @@ body { display: block; font-size: 16px; height: 48px; - width: 80%; + max-width: 100%; + width: auto; margin-left: auto; margin-right: auto; } @@ -645,11 +648,12 @@ body { section.slider-block { display: block; + margin-left: auto; + margin-right: auto; margin-bottom: 5%; } section.slider-block div.slider-content { - width: 80%; height: 500px; margin-left: auto; margin-right: auto; @@ -806,8 +810,10 @@ section.slider-block div.slider-content div.slider-control .light-right-icon { } .main-container-wrapper { - margin-left: 10%; - margin-right: 10%; + max-width: 80%; + width: auto; + margin-left: auto; + margin-right: auto; } .main-container-wrapper .content-container { @@ -815,50 +821,32 @@ section.slider-block div.slider-content div.slider-control .light-right-icon { width: 100%; } -.main-container-wrapper .main { - display: inline-block; - width: 75%; -} - .main-container-wrapper .product-grid { display: grid; grid-gap: 30px; } .main-container-wrapper .product-grid.max-2-col { - grid-template-columns: repeat(2, minmax(250px, 1fr)); + grid-template-columns: repeat(2, minmax(auto, 1fr)); } .main-container-wrapper .product-grid.max-3-col { - grid-template-columns: repeat(3, minmax(250px, 1fr)); + grid-template-columns: repeat(3, minmax(auto, 1fr)); } .main-container-wrapper .product-grid.max-4-col { - grid-template-columns: repeat(4, minmax(250px, 1fr)); -} - -.main-container-wrapper .product-grid .product-card { - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -ms-flex-flow: column; - flex-flow: column; - -webkit-box-pack: center; - -ms-flex-pack: center; - justify-content: center; + grid-template-columns: repeat(4, minmax(auto, 1fr)); } .main-container-wrapper .product-card .product-image { - background: #F2F2F2; margin-bottom: 10px; } .main-container-wrapper .product-card .product-image img { -ms-flex-item-align: center; align-self: center; - width: 100%; + max-width: 100%; + width: auto; margin-bottom: 14px; } diff --git a/public/themes/default/assets/js/shop.js b/public/themes/default/assets/js/shop.js index aee93be85..92989e592 100644 --- a/public/themes/default/assets/js/shop.js +++ b/public/themes/default/assets/js/shop.js @@ -10648,7 +10648,7 @@ return jQuery; "use strict"; /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*! - * Vue.js v2.5.17 + * Vue.js v2.5.16 * (c) 2014-2018 Evan You * Released under the MIT License. */ @@ -15737,7 +15737,7 @@ Object.defineProperty(Vue, 'FunctionalRenderContext', { value: FunctionalRenderContext }); -Vue.version = '2.5.17'; +Vue.version = '2.5.16'; /* */ diff --git a/public/themes/default/assets/mix-manifest.json b/public/themes/default/assets/mix-manifest.json index b7e923adb..2141a2aae 100644 --- a/public/themes/default/assets/mix-manifest.json +++ b/public/themes/default/assets/mix-manifest.json @@ -1,4 +1,4 @@ { "/js/shop.js": "/js/shop.js", "/css/shop.css": "/css/shop.css" -} +} \ No newline at end of file From 477dded06ef311e6af948c181db906b1bc6534d0 Mon Sep 17 00:00:00 2001 From: prashant-webkul Date: Sat, 15 Sep 2018 13:39:56 +0530 Subject: [PATCH 3/6] Product details page layout is fixed --- packages/Webkul/Cart/src/Cart.php | 3 +- .../Http/Controllers/SessionController.php | 3 + .../Http/Listeners/CustomerEventsHandler.php | 6 + packages/Webkul/Shop/src/Http/routes.php | 4 +- .../Shop/src/Resources/assets/sass/app.scss | 576 +++++++++--------- .../views/products/view/gallery.blade.php | 2 - public/themes/default/assets/css/shop.css | 270 ++------ 7 files changed, 348 insertions(+), 516 deletions(-) diff --git a/packages/Webkul/Cart/src/Cart.php b/packages/Webkul/Cart/src/Cart.php index 322c571ea..9145f8c18 100644 --- a/packages/Webkul/Cart/src/Cart.php +++ b/packages/Webkul/Cart/src/Cart.php @@ -292,7 +292,8 @@ class Cart { * and sync the cookies products * with the existing data of cart * in the cart tables; - */ + */ + public function mergeCart() { if(Cookie::has('cart_session_id')) { diff --git a/packages/Webkul/Customer/src/Http/Controllers/SessionController.php b/packages/Webkul/Customer/src/Http/Controllers/SessionController.php index d3017ed64..1ad764b39 100644 --- a/packages/Webkul/Customer/src/Http/Controllers/SessionController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/SessionController.php @@ -71,6 +71,9 @@ class SessionController extends Controller public function destroy($id) { auth()->guard('customer')->logout(); + + Event::fire('customer.after.logout', 1); + return redirect()->route($this->_config['redirect']); } } \ No newline at end of file diff --git a/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php b/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php index c14b422d2..bb6bba8ec 100644 --- a/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php +++ b/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php @@ -30,6 +30,10 @@ class CustomerEventsHandler { Cart::mergeCart(); } + //use this when there is very uttermost need to use it. + public function onCustomerLogout($event) { + } + /** * Register the listeners for the subscriber. * @@ -39,5 +43,7 @@ class CustomerEventsHandler { public function subscribe($events) { $events->listen('customer.after.login', 'Webkul\Customer\Http\Listeners\CustomerEventsHandler@onCustomerLogin'); + + $events->listen('customer.after.logout', 'Webkul\Customer\Http\Listeners\CustomerEventsHandler@onCustomerLogout'); } } \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Http/routes.php b/packages/Webkul/Shop/src/Http/routes.php index f37645460..2f4382ce2 100644 --- a/packages/Webkul/Shop/src/Http/routes.php +++ b/packages/Webkul/Shop/src/Http/routes.php @@ -23,9 +23,9 @@ Route::group(['middleware' => ['web']], function () { // //Routes for product cart - Route::post('products/guest/cart/add/{id}', 'Webkul\Cart\Http\Controllers\CartController@add')->name('cart.add'); + Route::post('products/add/{id}', 'Webkul\Cart\Http\Controllers\CartController@add')->name('cart.add'); - Route::post('product/guest/cart/remove/{id}', 'Webkul\Cart\Http\Controllers\CartController@remove')->name('cart.remove'); + Route::post('product/remove/{id}', 'Webkul\Cart\Http\Controllers\CartController@remove')->name('cart.remove'); // Route::post('product/customer/cart/add/{id}', 'Webkul\Cart\Http\Controllers\CartController@add')->name('cart.customer.add'); diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss index 575420e13..2fbcbcb14 100644 --- a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss +++ b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss @@ -1313,347 +1313,337 @@ section.product-detail { } div.layouter { + display: block; margin-top: 20px; margin-bottom: 20px; - display: inline-block; - width: 100%; - .mixed-group { + form { + display: flex; + flex-direction: row; + justify-content: space-between; + width: 100%; - .single-image { - padding: 2px; + div.product-image-group { + margin-right: 36px; - img { - height: 280px; - width: 280px; + div { + display: flex; + flex-direction: row; + + .thumb-list { + display: flex; + flex-direction: column; + margin-right: 4px; + height: 480px; + width: 120px; + overflow: hidden; + position: relative; + justify-content: flex-start; + + .thumb-frame { + border: 2px solid transparent; + background: #F2F2F2; + max-width: 120px; + width: auto; + height: 120px; + + &.active { + border-color: #979797; + } + + img { + width: 100%; + height: 100%; + } + } + + .gallery-control { + width: 100%; + position: absolute; + text-align: center; + cursor: pointer; + z-index: 1; + + .overlay { + opacity: 0.3; + background: #000000; + width: 100%; + height: 18px; + position: absolute; + left: 0; + z-index: -1; + } + + .icon { + z-index: 2; + } + + &.top { + top: 0; + } + + &.bottom { + bottom: 0; + } + } + } + + .product-hero-image { + display: block; + position: relative; + background: #F2F2F2; + width: 480px; + max-height: 480px; + + .wishlist { + position: absolute; + top: 10px; + right: 12px; + } + + .share { + position: absolute; + top: 10px; + right: 45px; + } + } + } + + .cart-fav-seg { + display: block; + float: right; } } .details { - - .product-name { - margin-top: 20px; - font-size: 24px; - margin-bottom: 20px; - } + width: 50%; .product-price { margin-bottom: 14px; } - } - } - .rating-reviews { - margin-top: 0px; - width: 50%; - margin-left: 20px; - - .title-inline { - display: inline-flex; - align-items: center; - justify-content: space-between; - margin-bottom: 20px; - width: 100%; - - button { - float: right; - border-radius: 0px !important; - } - } - - .overall { - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; - height: 150px; - - .left-side { + .product-ratings { margin-bottom: 20px; - .number{ - font-size: 34px; - } - } - - .right-side { - display: block; - - .rater { - display: inline-flex; - align-items: center; - - .star { - width: 50px; - height: 20px; - padding: 1px; - margin-right: 8px; - } - - .line-bar { - height: 4px; - width: 158px; - margin-right: 12px; - background: $bar-color; - - .line-value { - background-color: $dark-blue-shade; - } - } - } - } - } - - .reviews { - margin-top: 34px; - margin-bottom: 90px; - - .review { - margin-bottom: 25px; - - .title { - margin-bottom: 5px; - } - - .stars { - margin-bottom: 15px; - } - .message { - margin-bottom: 10px; - } - } - .view-all { - margin-top:15px; - color: $logo-color; - margin-bottom:15px; - } - } - } - - div.product-image-group { - width: 43%; - float: left; - min-height: 1px; - position: relative; - - .thumb-list { - display: flex; - flex-direction: column; - margin-right: 4px; - height: 480px; - overflow: hidden; - position: relative; - float: left; - - .thumb-frame { - border: 2px solid transparent; - background: #F2F2F2; - width: 120px; - height: 120px; - - &.active { - border-color: #979797; - } - - img { - width: 100%; - height: 100%; - } - } - - .gallery-control { - width: 100%; - position: absolute; - text-align: center; - cursor: pointer; - z-index: 1; - - .overlay { - opacity: 0.3; - background: #000000; - width: 100%; - height: 18px; - position: absolute; - left: 0; - z-index: -1; - } - .icon { - z-index: 2; + width: 16px; + height: 16px; } - &.top { - top: 0; - } - - &.bottom { - bottom: 0; + .total-reviews { + display: inline-block; + margin-left: 15px; } } - } - .product-hero-image { - display: block; - position: relative; - background: #F2F2F2; - width: 480px; - max-height: 480px; - float: left; - - .wishlist { - position: absolute; - top: 10px; - right: 12px; - } - - .share { - position: absolute; - top: 10px; - right: 45px; - } - } - } - - .details { - width: 57%; - float: left; - - .product-price { - margin-bottom: 14px; - } - - .product-ratings { - margin-bottom: 20px; - - .icon { - width: 16px; - height: 16px; - } - - .total-reviews { - display: inline-block; - margin-left: 15px; - } - } - - .product-heading { - font-size: 24px; - color: $product-font-color; - margin-bottom: 15px; - } - - .product-price { - margin-bottom: 15px; - font-size: 24px; - - .special-price { + .product-heading { font-size: 24px; + color: $product-font-color; + margin-bottom: 15px; } - } - .stock-status { - margin-bottom: 15px; - } + .product-price { + margin-bottom: 15px; + font-size: 24px; - .description { - margin-bottom: 15px; - padding-bottom: 15px; - border-bottom: solid 1px rgba(162, 162, 162, 0.2) - } - - .full-specifications { - td { - padding: 10px 0; - color: #5E5E5E; - - &:first-child { - padding-right: 40px; + .special-price { + font-size: 24px; } } + + .stock-status { + margin-bottom: 15px; + } + + .description { + margin-bottom: 15px; + padding-bottom: 15px; + border-bottom: solid 1px rgba(162, 162, 162, 0.2) + } + + .full-specifications { + td { + padding: 10px 0; + color: #5E5E5E; + + &:first-child { + padding-right: 40px; + } + } + } + + .accordian .accordian-header { + font-size: 16px; + padding-left: 0; + font-weight: 600; + } + + .attributes { + display: block; + width: 100%; + border-bottom: solid 1px rgba(162, 162, 162, 0.2); + } + + .full-description { + font-size: 16px; + } } - .accordian .accordian-header { - font-size: 16px; - padding-left: 0; - font-weight: 600; - } + // .rating-reviews { + // margin-top: 0px; + // width: 50%; + // margin-left: 20px; + + // .title-inline { + // display: inline-flex; + // align-items: center; + // justify-content: space-between; + // margin-bottom: 20px; + // width: 100%; + + // button { + // float: right; + // border-radius: 0px !important; + // } + // } + + // .overall { + // display: flex; + // flex-direction: row; + // align-items: center; + // justify-content: space-between; + // height: 150px; + + // .left-side { + // margin-bottom: 20px; + + // .number{ + // font-size: 34px; + // } + // } + + // .right-side { + // display: block; + + // .rater { + // display: inline-flex; + // align-items: center; + + // .star { + // width: 50px; + // height: 20px; + // padding: 1px; + // margin-right: 8px; + // } + + // .line-bar { + // height: 4px; + // width: 158px; + // margin-right: 12px; + // background: $bar-color; + + // .line-value { + // background-color: $dark-blue-shade; + // } + // } + // } + // } + // } + + // .reviews { + // margin-top: 34px; + // margin-bottom: 90px; + + // .review { + // margin-bottom: 25px; + + // .title { + // margin-bottom: 5px; + // } + + // .stars { + // margin-bottom: 15px; + // } + // .message { + // margin-bottom: 10px; + // } + // } + // .view-all { + // margin-top:15px; + // color: $logo-color; + // margin-bottom:15px; + // } + // } + // } - .attributes { - display: block; - width: 100%; - border-bottom: solid 1px rgba(162, 162, 162, 0.2); - } - .full-description { - font-size: 16px; - } } } } -.rating-reviews { +// .rating-reviews { - .rating-header { - font-weight: 600; - padding: 20px 0; - } +// .rating-header { +// font-weight: 600; +// padding: 20px 0; +// } - .stars { - .icon { - width: 16px; - height: 16px; - } - } +// .stars { +// .icon { +// width: 16px; +// height: 16px; +// } +// } - .overall { - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; +// .overall { +// display: flex; +// flex-direction: row; +// align-items: center; +// justify-content: space-between; - .review-info { - .number { - font-size: 34px; - } +// .review-info { +// .number { +// font-size: 34px; +// } - .total-reviews { - margin-top: 10px; - } - } - } +// .total-reviews { +// margin-top: 10px; +// } +// } +// } - .reviews { - margin-top: 40px; - margin-bottom: 40px; +// .reviews { +// margin-top: 40px; +// margin-bottom: 40px; - .review { - margin-bottom: 25px; +// .review { +// margin-bottom: 25px; - .title { - margin-bottom: 5px; - } +// .title { +// margin-bottom: 5px; +// } - .stars { - margin-bottom: 15px; - display: inline-block; - } +// .stars { +// margin-bottom: 15px; +// display: inline-block; +// } - .message { - margin-bottom: 10px; - } +// .message { +// margin-bottom: 10px; +// } - .reviewer-details { - color: #5E5E5E; - } - } +// .reviewer-details { +// color: #5E5E5E; +// } +// } - .view-all { - margin-top:15px; - color: $logo-color; - margin-bottom:15px; - } - } -} +// .view-all { +// margin-top:15px; +// color: $logo-color; +// margin-bottom:15px; +// } +// } +// } /* cart pages and elements css begins here */ section.cart { diff --git a/packages/Webkul/Shop/src/Resources/views/products/view/gallery.blade.php b/packages/Webkul/Shop/src/Resources/views/products/view/gallery.blade.php index acd1e6dbc..54c605929 100644 --- a/packages/Webkul/Shop/src/Resources/views/products/view/gallery.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/view/gallery.blade.php @@ -5,9 +5,7 @@
- @include ('shop::products.add-to') -
@push('scripts') diff --git a/public/themes/default/assets/css/shop.css b/public/themes/default/assets/css/shop.css index 064cd197d..f15ae984f 100644 --- a/public/themes/default/assets/css/shop.css +++ b/public/themes/default/assets/css/shop.css @@ -1378,57 +1378,12 @@ section.product-detail div.category-breadcrumbs { } section.product-detail div.layouter { + display: block; margin-top: 20px; margin-bottom: 20px; - display: inline-block; - width: 100%; } -section.product-detail div.layouter .mixed-group .single-image { - padding: 2px; -} - -section.product-detail div.layouter .mixed-group .single-image img { - height: 280px; - width: 280px; -} - -section.product-detail div.layouter .mixed-group .details .product-name { - margin-top: 20px; - font-size: 24px; - margin-bottom: 20px; -} - -section.product-detail div.layouter .mixed-group .details .product-price { - margin-bottom: 14px; -} - -section.product-detail div.layouter .rating-reviews { - margin-top: 0px; - width: 50%; - margin-left: 20px; -} - -section.product-detail div.layouter .rating-reviews .title-inline { - display: -webkit-inline-box; - display: -ms-inline-flexbox; - display: inline-flex; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - -webkit-box-pack: justify; - -ms-flex-pack: justify; - justify-content: space-between; - margin-bottom: 20px; - width: 100%; -} - -section.product-detail div.layouter .rating-reviews .title-inline button { - float: right; - border-radius: 0px !important; -} - -section.product-detail div.layouter .rating-reviews .overall { +section.product-detail div.layouter form { display: -webkit-box; display: -ms-flexbox; display: flex; @@ -1436,89 +1391,27 @@ section.product-detail div.layouter .rating-reviews .overall { -webkit-box-direction: normal; -ms-flex-direction: row; flex-direction: row; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; -webkit-box-pack: justify; -ms-flex-pack: justify; justify-content: space-between; - height: 150px; + width: 100%; } -section.product-detail div.layouter .rating-reviews .overall .left-side { - margin-bottom: 20px; +section.product-detail div.layouter form div.product-image-group { + margin-right: 36px; } -section.product-detail div.layouter .rating-reviews .overall .left-side .number { - font-size: 34px; +section.product-detail div.layouter form div.product-image-group div { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -ms-flex-direction: row; + flex-direction: row; } -section.product-detail div.layouter .rating-reviews .overall .right-side { - display: block; -} - -section.product-detail div.layouter .rating-reviews .overall .right-side .rater { - display: -webkit-inline-box; - display: -ms-inline-flexbox; - display: inline-flex; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; -} - -section.product-detail div.layouter .rating-reviews .overall .right-side .rater .star { - width: 50px; - height: 20px; - padding: 1px; - margin-right: 8px; -} - -section.product-detail div.layouter .rating-reviews .overall .right-side .rater .line-bar { - height: 4px; - width: 158px; - margin-right: 12px; - background: #D8D8D8; -} - -section.product-detail div.layouter .rating-reviews .overall .right-side .rater .line-bar .line-value { - background-color: #0031F0; -} - -section.product-detail div.layouter .rating-reviews .reviews { - margin-top: 34px; - margin-bottom: 90px; -} - -section.product-detail div.layouter .rating-reviews .reviews .review { - margin-bottom: 25px; -} - -section.product-detail div.layouter .rating-reviews .reviews .review .title { - margin-bottom: 5px; -} - -section.product-detail div.layouter .rating-reviews .reviews .review .stars { - margin-bottom: 15px; -} - -section.product-detail div.layouter .rating-reviews .reviews .review .message { - margin-bottom: 10px; -} - -section.product-detail div.layouter .rating-reviews .reviews .view-all { - margin-top: 15px; - color: #0031f0; - margin-bottom: 15px; -} - -section.product-detail div.layouter div.product-image-group { - width: 43%; - float: left; - min-height: 1px; - position: relative; -} - -section.product-detail div.layouter div.product-image-group .thumb-list { +section.product-detail div.layouter form div.product-image-group div .thumb-list { display: -webkit-box; display: -ms-flexbox; display: flex; @@ -1528,28 +1421,32 @@ section.product-detail div.layouter div.product-image-group .thumb-list { flex-direction: column; margin-right: 4px; height: 480px; + width: 120px; overflow: hidden; position: relative; - float: left; + -webkit-box-pack: start; + -ms-flex-pack: start; + justify-content: flex-start; } -section.product-detail div.layouter div.product-image-group .thumb-list .thumb-frame { +section.product-detail div.layouter form div.product-image-group div .thumb-list .thumb-frame { border: 2px solid transparent; background: #F2F2F2; - width: 120px; + max-width: 120px; + width: auto; height: 120px; } -section.product-detail div.layouter div.product-image-group .thumb-list .thumb-frame.active { +section.product-detail div.layouter form div.product-image-group div .thumb-list .thumb-frame.active { border-color: #979797; } -section.product-detail div.layouter div.product-image-group .thumb-list .thumb-frame img { +section.product-detail div.layouter form div.product-image-group div .thumb-list .thumb-frame img { width: 100%; height: 100%; } -section.product-detail div.layouter div.product-image-group .thumb-list .gallery-control { +section.product-detail div.layouter form div.product-image-group div .thumb-list .gallery-control { width: 100%; position: absolute; text-align: center; @@ -1557,7 +1454,7 @@ section.product-detail div.layouter div.product-image-group .thumb-list .gallery z-index: 1; } -section.product-detail div.layouter div.product-image-group .thumb-list .gallery-control .overlay { +section.product-detail div.layouter form div.product-image-group div .thumb-list .gallery-control .overlay { opacity: 0.3; background: #000000; width: 100%; @@ -1567,178 +1464,115 @@ section.product-detail div.layouter div.product-image-group .thumb-list .gallery z-index: -1; } -section.product-detail div.layouter div.product-image-group .thumb-list .gallery-control .icon { +section.product-detail div.layouter form div.product-image-group div .thumb-list .gallery-control .icon { z-index: 2; } -section.product-detail div.layouter div.product-image-group .thumb-list .gallery-control.top { +section.product-detail div.layouter form div.product-image-group div .thumb-list .gallery-control.top { top: 0; } -section.product-detail div.layouter div.product-image-group .thumb-list .gallery-control.bottom { +section.product-detail div.layouter form div.product-image-group div .thumb-list .gallery-control.bottom { bottom: 0; } -section.product-detail div.layouter div.product-image-group .product-hero-image { +section.product-detail div.layouter form div.product-image-group div .product-hero-image { display: block; position: relative; background: #F2F2F2; width: 480px; max-height: 480px; - float: left; } -section.product-detail div.layouter div.product-image-group .product-hero-image .wishlist { +section.product-detail div.layouter form div.product-image-group div .product-hero-image .wishlist { position: absolute; top: 10px; right: 12px; } -section.product-detail div.layouter div.product-image-group .product-hero-image .share { +section.product-detail div.layouter form div.product-image-group div .product-hero-image .share { position: absolute; top: 10px; right: 45px; } -section.product-detail div.layouter .details { - width: 57%; - float: left; +section.product-detail div.layouter form div.product-image-group .cart-fav-seg { + display: block; + float: right; } -section.product-detail div.layouter .details .product-price { +section.product-detail div.layouter form .details { + width: 50%; +} + +section.product-detail div.layouter form .details .product-price { margin-bottom: 14px; } -section.product-detail div.layouter .details .product-ratings { +section.product-detail div.layouter form .details .product-ratings { margin-bottom: 20px; } -section.product-detail div.layouter .details .product-ratings .icon { +section.product-detail div.layouter form .details .product-ratings .icon { width: 16px; height: 16px; } -section.product-detail div.layouter .details .product-ratings .total-reviews { +section.product-detail div.layouter form .details .product-ratings .total-reviews { display: inline-block; margin-left: 15px; } -section.product-detail div.layouter .details .product-heading { +section.product-detail div.layouter form .details .product-heading { font-size: 24px; color: #242424; margin-bottom: 15px; } -section.product-detail div.layouter .details .product-price { +section.product-detail div.layouter form .details .product-price { margin-bottom: 15px; font-size: 24px; } -section.product-detail div.layouter .details .product-price .special-price { +section.product-detail div.layouter form .details .product-price .special-price { font-size: 24px; } -section.product-detail div.layouter .details .stock-status { +section.product-detail div.layouter form .details .stock-status { margin-bottom: 15px; } -section.product-detail div.layouter .details .description { +section.product-detail div.layouter form .details .description { margin-bottom: 15px; padding-bottom: 15px; border-bottom: solid 1px rgba(162, 162, 162, 0.2); } -section.product-detail div.layouter .details .full-specifications td { +section.product-detail div.layouter form .details .full-specifications td { padding: 10px 0; color: #5E5E5E; } -section.product-detail div.layouter .details .full-specifications td:first-child { +section.product-detail div.layouter form .details .full-specifications td:first-child { padding-right: 40px; } -section.product-detail div.layouter .details .accordian .accordian-header { +section.product-detail div.layouter form .details .accordian .accordian-header { font-size: 16px; padding-left: 0; font-weight: 600; } -section.product-detail div.layouter .details .attributes { +section.product-detail div.layouter form .details .attributes { display: block; width: 100%; border-bottom: solid 1px rgba(162, 162, 162, 0.2); } -section.product-detail div.layouter .details .full-description { +section.product-detail div.layouter form .details .full-description { font-size: 16px; } -.rating-reviews .rating-header { - font-weight: 600; - padding: 20px 0; -} - -.rating-reviews .stars .icon { - width: 16px; - height: 16px; -} - -.rating-reviews .overall { - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: horizontal; - -webkit-box-direction: normal; - -ms-flex-direction: row; - flex-direction: row; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - -webkit-box-pack: justify; - -ms-flex-pack: justify; - justify-content: space-between; -} - -.rating-reviews .overall .review-info .number { - font-size: 34px; -} - -.rating-reviews .overall .review-info .total-reviews { - margin-top: 10px; -} - -.rating-reviews .reviews { - margin-top: 40px; - margin-bottom: 40px; -} - -.rating-reviews .reviews .review { - margin-bottom: 25px; -} - -.rating-reviews .reviews .review .title { - margin-bottom: 5px; -} - -.rating-reviews .reviews .review .stars { - margin-bottom: 15px; - display: inline-block; -} - -.rating-reviews .reviews .review .message { - margin-bottom: 10px; -} - -.rating-reviews .reviews .review .reviewer-details { - color: #5E5E5E; -} - -.rating-reviews .reviews .view-all { - margin-top: 15px; - color: #0031f0; - margin-bottom: 15px; -} - /* cart pages and elements css begins here */ section.cart { color: #242424; From dbfe16e3bdb3fdfea085a4f9fe3c3706d11d3f95 Mon Sep 17 00:00:00 2001 From: prashant-webkul Date: Sat, 15 Sep 2018 14:46:16 +0530 Subject: [PATCH 4/6] Rework the merge function else all would be fine --- packages/Webkul/Cart/src/Cart.php | 223 +++++++++++------- .../Shop/src/Resources/assets/sass/app.scss | 6 + .../Resources/views/products/add-to.blade.php | 6 +- public/themes/default/assets/css/shop.css | 6 + 4 files changed, 148 insertions(+), 93 deletions(-) diff --git a/packages/Webkul/Cart/src/Cart.php b/packages/Webkul/Cart/src/Cart.php index 9145f8c18..6df54b6e0 100644 --- a/packages/Webkul/Cart/src/Cart.php +++ b/packages/Webkul/Cart/src/Cart.php @@ -297,103 +297,146 @@ class Cart { public function mergeCart() { if(Cookie::has('cart_session_id')) { + /* + Check for previous cart of customer and + pull products from that cart instance + and then check for unique products + and delete the record with session id + and increase the quantity of the products + that are added again before deleting the + guest cart record. + */ + //To hold the customer ID which is currently logged in + $customer_id = auth()->guard('customer')->user()->id; + + //having the session id saved in the cart. $cart_session_id = Cookie::get('cart_session_id'); - $current_cart = $this->cart->findOneByField('session_id', $cart_session_id); + //pull the record from cart table for above session id. + $guest_cart = $this->cart->findOneByField($cart_session_id); - //it is impossible to not have an entry in cart table and cart_products. - //will later handle the exceoption. - $current_cart_id = $current_cart['id'] ?? $current_cart->id; + if(!isset($guest_cart)) { + dd('Some One Deleted Cart or it wasn\'t there from the start'); - $current_cart_session_id = $current_cart['session_id'] ?? $current_cart->session_id; - - $current_cart_products = $this->cart->getProducts($current_cart_id); - - $customer_id = auth()->guard('customer')->user()->id; //working - - if($cart_session_id == $current_cart_session_id) { - $current_cart_products = array(); - - $customer_cart = $this->cart->findByField(['customer_id'=> $customer_id]); - - //check previous saved cart of customer. - if(!$customer_cart->isEmpty()) { - - $customer_cart_id = $customer_cart->id; - - $customer_cart_products = $this->cart->getProducts($customer_cart_id); - - foreach($current_cart_products as $key => $value) { - - $product_id = $value['id'] ?? $value->id; - - foreach($current_cart_products as $key => $current_cart_product) { - - $current_product_id = $current_cart_product['id'] ?? $current_cart_product->id; - - if($current_product_id == $product_id) { - - unset($current_cart_products[$key]); - } - } - } - - - foreach($current_cart_products as $current_cart_product) { - - $current_cart_product_id = $current_cart_product['id'] ?? $current_cart_product->id; - - $this->cart->attach($current_cart_id, $current_cart_product_id, 1); - } - - $this->cart->update(['customer_id' => $customer_id], $current_cart_id); - - $customer_cart = $this->cart->findOneByField('customer_id', $customer_id); - - $customer_cart_id = $customer_cart->id; - - if($this->cart->getProducts($customer_cart_id) && isset($current_cart_products)) { - foreach($current_cart_products as $key => $value) { - - array_push($cart_products, $current_cart_product); - } - } - - session()->put('cart_data', [$customer_cart, $cart_products]); - - session()->flash('Success', 'Item Added In Cart'); - - dump($cart_products); - - return redirect()->back(); - } else { - - $session_id = session()->getId(); - - $customer_id = auth()->guard('customer')->user()->id; - - $updated_cart = $this->cart->update(['customer_id' => $customer_id, 'session_id' => $session_id], $current_cart_id); - - $updated_cart_products = $this->cart->getProducts($updated_cart->id); - - Cookie::queue('cart_session_id', $session_id, 120); - - session()->put('cart_session_id', $session_id); - - session('cart_data', [$updated_cart, $updated_cart_products]); - - return redirect()->back(); - } - } else { - throw new \Exception('Error, Session discrepancies found.'); - - $this->repairCart($cart_session_id, $id); + return redirect()->back(); } - } else { - throw new \Exception('Nothing found'); - return redirect()->back(); + //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(Cookie::has('cart_session_id')) { + + // /* + // Check for previous cart of customer and + // pull products from that cart instance + // and then check for unique products + // and delete the record with session id + // and increase the quantity of the products + // that are added again before deleting the + // guest cart record. + // */ + + // $cart_session_id = Cookie::get('cart_session_id'); + + // $current_cart = $this->cart->findOneByField('session_id', $cart_session_id); + + // //it is impossible to not have an entry in cart table and cart_products. + // //will later handle the exceoption. + // $current_cart_id = $current_cart['id'] ?? $current_cart->id; + + // $current_cart_session_id = $current_cart['session_id'] ?? $current_cart->session_id; + + // $current_cart_products = $this->cart->getProducts($current_cart_id); + + // $customer_id = auth()->guard('customer')->user()->id; //working + + // if($cart_session_id == $current_cart_session_id) { + // $current_cart_products = array(); + + // $customer_cart = $this->cart->findByField(['customer_id'=> $customer_id]); + + // //check previous saved cart of customer. + // if(!$customer_cart->isEmpty()) { + + // $customer_cart_id = $customer_cart->id; + + // $customer_cart_products = $this->cart->getProducts($customer_cart_id); + + // foreach($current_cart_products as $key => $value) { + + // $product_id = $value['id'] ?? $value->id; + + // foreach($current_cart_products as $key => $current_cart_product) { + + // $current_product_id = $current_cart_product['id'] ?? $current_cart_product->id; + + // if($current_product_id == $product_id) { + + // unset($current_cart_products[$key]); + // } + // } + // } + + + // foreach($current_cart_products as $current_cart_product) { + + // $current_cart_product_id = $current_cart_product['id'] ?? $current_cart_product->id; + + // $this->cart->attach($current_cart_id, $current_cart_product_id, 1); + // } + + // $this->cart->update(['customer_id' => $customer_id], $current_cart_id); + + // $customer_cart = $this->cart->findOneByField('customer_id', $customer_id); + + // $customer_cart_id = $customer_cart->id; + + // if($this->cart->getProducts($customer_cart_id) && isset($current_cart_products)) { + // foreach($current_cart_products as $key => $value) { + + // array_push($cart_products, $current_cart_product); + // } + // } + + // session()->put('cart_data', [$customer_cart, $cart_products]); + + // session()->flash('Success', 'Item Added In Cart'); + + // dump($cart_products); + + // return redirect()->back(); + // } else { + + // $session_id = session()->getId(); + + // $customer_id = auth()->guard('customer')->user()->id; + + // $updated_cart = $this->cart->update(['customer_id' => $customer_id, 'session_id' => $session_id], $current_cart_id); + + // $updated_cart_products = $this->cart->getProducts($updated_cart->id); + + // Cookie::queue('cart_session_id', $session_id, 120); + + // session()->put('cart_session_id', $session_id); + + // session('cart_data', [$updated_cart, $updated_cart_products]); + + // return redirect()->back(); + // } + // } else { + // throw new \Exception('Error, Session discrepancies found.'); + + // $this->repairCart($cart_session_id, $id); + // } + // } else { + // throw new \Exception('Nothing found'); + + // return redirect()->back(); + // } } } \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss index 2fbcbcb14..799e0760b 100644 --- a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss +++ b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss @@ -1412,6 +1412,12 @@ section.product-detail { .cart-fav-seg { display: block; float: right; + + .wishlist { + position: absolute; + margin-top: -500px; + margin-right: -100px; + } } } diff --git a/packages/Webkul/Shop/src/Resources/views/products/add-to.blade.php b/packages/Webkul/Shop/src/Resources/views/products/add-to.blade.php index 1839cb16b..1ebdd16b1 100644 --- a/packages/Webkul/Shop/src/Resources/views/products/add-to.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/add-to.blade.php @@ -1,7 +1,7 @@
- + @include ('shop::products.add-to-cart', ['product' => $product]) - - + +
\ No newline at end of file diff --git a/public/themes/default/assets/css/shop.css b/public/themes/default/assets/css/shop.css index f15ae984f..b674c2995 100644 --- a/public/themes/default/assets/css/shop.css +++ b/public/themes/default/assets/css/shop.css @@ -1501,6 +1501,12 @@ section.product-detail div.layouter form div.product-image-group .cart-fav-seg { float: right; } +section.product-detail div.layouter form div.product-image-group .cart-fav-seg .wishlist { + position: absolute; + margin-top: -500px; + margin-right: -100px; +} + section.product-detail div.layouter form .details { width: 50%; } From ec6d777b25aa36eb11cf63894e59fd14c0b44f07 Mon Sep 17 00:00:00 2001 From: prashant-webkul Date: Mon, 17 Sep 2018 13:57:32 +0530 Subject: [PATCH 5/6] Cart Working by adding the products as guest and logged in user and merging in case of guest user to logged in. Ready for next phase of checkouts. --- packages/Webkul/Cart/src/Cart.php | 178 ++++++------------ .../src/Http/Controllers/CartController.php | 19 +- packages/Webkul/Cart/src/Models/Cart.php | 2 +- .../Cart/src/Repositories/CartRepository.php | 41 +++- packages/Webkul/Shop/src/Http/routes.php | 2 + 5 files changed, 113 insertions(+), 129 deletions(-) diff --git a/packages/Webkul/Cart/src/Cart.php b/packages/Webkul/Cart/src/Cart.php index 6df54b6e0..9969c4f23 100644 --- a/packages/Webkul/Cart/src/Cart.php +++ b/packages/Webkul/Cart/src/Cart.php @@ -45,7 +45,7 @@ class Cart { $products = array(); - $minutes = 10; + $minutes = 150; if(Cookie::has('cart_session_id')) { @@ -95,21 +95,16 @@ class Cart { return redirect()->back(); } else { - // throw new \Exception('Error, Many or Few Session discrepancies found.'); - + //repair the cart $this->repairCart($cart_session_id, $id); } } else { + //create a new cart instance. $this->createNewCart($id); } } /*helpers*/ - public function makeCartSession($to_process) { - session()->put('cart_session_id', $to_process); - - return session()->get('cart_session_id'); - } /** * Create New Cart @@ -156,6 +151,17 @@ class Cart { return redirect()->back(); } + /** + * This makes session + * cart. + */ + public function makeCartSession($cart_session_id) { + session()->put('cart_session_id', $cart_session_id); + + return session()->get('cart_session_id'); + } + + /** * Reset Session and * Cookie values @@ -296,6 +302,7 @@ class Cart { public function mergeCart() { + //considering cookie as a source of truth. if(Cookie::has('cart_session_id')) { /* Check for previous cart of customer and @@ -314,7 +321,7 @@ class Cart { $cart_session_id = Cookie::get('cart_session_id'); //pull the record from cart table for above session id. - $guest_cart = $this->cart->findOneByField($cart_session_id); + $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'); @@ -322,121 +329,54 @@ class Cart { return redirect()->back(); } + $guest_cart_products = $this->cart->getProducts($guest_cart->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); + foreach($guest_cart_products as $key => $guest_cart_product) { + + foreach($customer_cart_products as $customer_cart_product) { + + if($guest_cart_product->id == $customer_cart_product->id) { + + $quantity = $guest_cart_product->toArray()['pivot']['quantity'] + 1; + + $pivot = $guest_cart_product->toArray()['pivot']; + + $saveQuantity = $this->cart->updateRelatedForMerge($pivot, 'quantity', $quantity); + + unset($guest_cart_products[$key]); + } + } + } + + //insert the new products here. + foreach ($guest_cart_products as $key => $guest_cart_product) { + $product = $guest_cart_product->toArray(); + + $this->cart->updateRelatedForMerge($product['pivot'], 'cart_id', $customer_cart->id); + } + + //detach with guest cart records + $this->cart->detachAndDeleteParent($guest_cart->id); + + Cookie::queue(Cookie::forget('cart_session_id')); + + return redirect()->back(); + } else { + //this will just update the customer id column in the cart table + $this->cart->update(['customer_id' => $customer_id], $guest_cart->id); + + Cookie::queue(Cookie::forget('cart_session_id')); + + return redirect()->back(); + } } - - // if(Cookie::has('cart_session_id')) { - - // /* - // Check for previous cart of customer and - // pull products from that cart instance - // and then check for unique products - // and delete the record with session id - // and increase the quantity of the products - // that are added again before deleting the - // guest cart record. - // */ - - // $cart_session_id = Cookie::get('cart_session_id'); - - // $current_cart = $this->cart->findOneByField('session_id', $cart_session_id); - - // //it is impossible to not have an entry in cart table and cart_products. - // //will later handle the exceoption. - // $current_cart_id = $current_cart['id'] ?? $current_cart->id; - - // $current_cart_session_id = $current_cart['session_id'] ?? $current_cart->session_id; - - // $current_cart_products = $this->cart->getProducts($current_cart_id); - - // $customer_id = auth()->guard('customer')->user()->id; //working - - // if($cart_session_id == $current_cart_session_id) { - // $current_cart_products = array(); - - // $customer_cart = $this->cart->findByField(['customer_id'=> $customer_id]); - - // //check previous saved cart of customer. - // if(!$customer_cart->isEmpty()) { - - // $customer_cart_id = $customer_cart->id; - - // $customer_cart_products = $this->cart->getProducts($customer_cart_id); - - // foreach($current_cart_products as $key => $value) { - - // $product_id = $value['id'] ?? $value->id; - - // foreach($current_cart_products as $key => $current_cart_product) { - - // $current_product_id = $current_cart_product['id'] ?? $current_cart_product->id; - - // if($current_product_id == $product_id) { - - // unset($current_cart_products[$key]); - // } - // } - // } - - - // foreach($current_cart_products as $current_cart_product) { - - // $current_cart_product_id = $current_cart_product['id'] ?? $current_cart_product->id; - - // $this->cart->attach($current_cart_id, $current_cart_product_id, 1); - // } - - // $this->cart->update(['customer_id' => $customer_id], $current_cart_id); - - // $customer_cart = $this->cart->findOneByField('customer_id', $customer_id); - - // $customer_cart_id = $customer_cart->id; - - // if($this->cart->getProducts($customer_cart_id) && isset($current_cart_products)) { - // foreach($current_cart_products as $key => $value) { - - // array_push($cart_products, $current_cart_product); - // } - // } - - // session()->put('cart_data', [$customer_cart, $cart_products]); - - // session()->flash('Success', 'Item Added In Cart'); - - // dump($cart_products); - - // return redirect()->back(); - // } else { - - // $session_id = session()->getId(); - - // $customer_id = auth()->guard('customer')->user()->id; - - // $updated_cart = $this->cart->update(['customer_id' => $customer_id, 'session_id' => $session_id], $current_cart_id); - - // $updated_cart_products = $this->cart->getProducts($updated_cart->id); - - // Cookie::queue('cart_session_id', $session_id, 120); - - // session()->put('cart_session_id', $session_id); - - // session('cart_data', [$updated_cart, $updated_cart_products]); - - // return redirect()->back(); - // } - // } else { - // throw new \Exception('Error, Session discrepancies found.'); - - // $this->repairCart($cart_session_id, $id); - // } - // } else { - // throw new \Exception('Nothing found'); - - // return redirect()->back(); - // } + return redirect()->back(); } } \ No newline at end of file diff --git a/packages/Webkul/Cart/src/Http/Controllers/CartController.php b/packages/Webkul/Cart/src/Http/Controllers/CartController.php index 972719384..101d28b9a 100644 --- a/packages/Webkul/Cart/src/Http/Controllers/CartController.php +++ b/packages/Webkul/Cart/src/Http/Controllers/CartController.php @@ -42,7 +42,7 @@ class CartController extends Controller public function __construct(CartRepository $cart, CartProductRepository $cartProduct, CustomerRepository $customer) { - $this->middleware('customer')->except(['add', 'remove']); + $this->middleware('customer')->except(['add', 'remove', 'test']); $this->customer = $customer; @@ -80,4 +80,21 @@ class CartController extends Controller return redirect()->back(); } + + // public function test() { + // $cookie = Cookie::get('cart_session_id'); + + // $cart = $this->cart->findOneByField('session_id', $cookie); + + // $cart_products = $this->cart->getProducts($cart->id); + + // foreach($cart_products as $cart_product) { + // $quantity = $cart_product->toArray()['pivot']['quantity'] + 1; + + // $pivot = $cart_product->toArray()['pivot']; + + // $saveQuantity = $this->cart->saveRelated($pivot, 'quantity', $quantity+1); + // } + // dd('done'); + // } } \ No newline at end of file diff --git a/packages/Webkul/Cart/src/Models/Cart.php b/packages/Webkul/Cart/src/Models/Cart.php index f03c3a82f..20f376f67 100644 --- a/packages/Webkul/Cart/src/Models/Cart.php +++ b/packages/Webkul/Cart/src/Models/Cart.php @@ -15,6 +15,6 @@ class Cart extends Model protected $hidden = ['coupon_code']; public function with_products() { - return $this->belongsToMany(Product::class, 'cart_products'); + return $this->belongsToMany(Product::class, 'cart_products')->withPivot('id', 'product_id','quantity', 'cart_id'); } } diff --git a/packages/Webkul/Cart/src/Repositories/CartRepository.php b/packages/Webkul/Cart/src/Repositories/CartRepository.php index 0ba0e4b07..e7f951abd 100644 --- a/packages/Webkul/Cart/src/Repositories/CartRepository.php +++ b/packages/Webkul/Cart/src/Repositories/CartRepository.php @@ -16,7 +16,7 @@ class CartRepository extends Repository /** * Specify Model class name * - * @return mixed + * @return Mixed */ function model() @@ -26,7 +26,7 @@ class CartRepository extends Repository /** * @param array $data - * @return mixed + * @return Mixed */ public function create(array $data) @@ -40,7 +40,7 @@ class CartRepository extends Repository * @param array $data * @param $id * @param string $attribute - * @return mixed + * @return Mixed */ public function update(array $data, $id, $attribute = "id") @@ -61,18 +61,43 @@ class CartRepository extends Repository * Method to attach * associations * - * @return Eloquent + * @return Mixed */ public function attach($cart_id, $product_id, $quantity) { - $this->model->findOrFail($cart_id)->with_products()->attach($cart_id, ['product_id' => $product_id, 'cart_id' => $cart_id, 'quantity' => $quantity]); + return $this->model->findOrFail($cart_id)->with_products()->attach($cart_id, ['product_id' => $product_id, 'cart_id' => $cart_id, 'quantity' => $quantity]); } /** - * Method to detach - * associations + * This will update the + * quantity of product + * for the customer, + * in case of merge. * - * @return Eloquent + * @return Mixed */ + public function updateRelatedForMerge($pivot, $column, $value) { + $cart_product = $this->model->findOrFail($pivot['cart_id']); + + return $cart_product->with_products()->updateExistingPivot($pivot['product_id'], array($column => $value)); + } + + /** + * Method to detach + * associations. + * + * Use this only with + * guest cart only. + * + * @return Mixed + */ + public function detachAndDeleteParent($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); + } } \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Http/routes.php b/packages/Webkul/Shop/src/Http/routes.php index 2f4382ce2..faf6223fc 100644 --- a/packages/Webkul/Shop/src/Http/routes.php +++ b/packages/Webkul/Shop/src/Http/routes.php @@ -2,6 +2,8 @@ Route::group(['middleware' => ['web']], function () { + Route::get('/test', 'Webkul\Cart\Http\Controllers\CartController@test'); + Route::get('/', 'Webkul\Shop\Http\Controllers\HomeController@index')->defaults('_config', [ 'view' => 'shop::home.index' ])->name('store.home'); From a24c789a3c12ca6138a64fb04c24b43770137a67 Mon Sep 17 00:00:00 2001 From: prashant-webkul Date: Wed, 19 Sep 2018 12:30:24 +0530 Subject: [PATCH 6/6] before merge --- .../views/users/users/index.blade.php | 1 - packages/Webkul/Cart/src/Cart.php | 136 ++++++--- .../src/Http/ViewComposers/CartComposer.php | 59 ++++ packages/Webkul/Cart/src/Models/Cart.php | 3 +- .../src/Providers/CartServiceProvider.php | 8 +- .../src/Providers/ComposerServiceProvider.php | 32 +++ packages/Webkul/Shop/src/Http/routes.php | 22 -- .../Shop/src/Resources/assets/js/app.js | 2 + .../assets/js/components/cart-dropdown.vue | 156 +++++++++++ .../assets/js/components/category-item.vue | 1 - .../Shop/src/Resources/assets/sass/app.scss | 27 +- .../Shop/src/Resources/assets/sass/icons.scss | 10 +- .../views/layouts/header/index.blade.php | 121 +------- .../Resources/views/products/view.blade.php | 1 - .../views/products/view/gallery.blade.php | 1 - .../assets/js/components/flash-wrapper.vue | 2 +- .../views/datagrid/table/default.blade.php | 8 +- packages/Webkul/Ui/webpack.mix.js | 2 +- public/themes/default/assets/css/shop.css | 30 +- public/themes/default/assets/js/shop.js | 265 +++++++++++++++++- resources/views/welcome.blade.php | 2 +- 21 files changed, 691 insertions(+), 198 deletions(-) create mode 100644 packages/Webkul/Cart/src/Http/ViewComposers/CartComposer.php create mode 100644 packages/Webkul/Cart/src/Providers/ComposerServiceProvider.php create mode 100644 packages/Webkul/Shop/src/Resources/assets/js/components/cart-dropdown.vue diff --git a/packages/Webkul/Admin/src/Resources/views/users/users/index.blade.php b/packages/Webkul/Admin/src/Resources/views/users/users/index.blade.php index fc4a1d6c3..466bd0e47 100644 --- a/packages/Webkul/Admin/src/Resources/views/users/users/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/users/users/index.blade.php @@ -3,7 +3,6 @@ @section('page_title') @endsection -@stop @section('content') diff --git a/packages/Webkul/Cart/src/Cart.php b/packages/Webkul/Cart/src/Cart.php index 9969c4f23..a580a8789 100644 --- a/packages/Webkul/Cart/src/Cart.php +++ b/packages/Webkul/Cart/src/Cart.php @@ -32,74 +32,88 @@ class Cart { protected $customer; - public function __construct(CartRepository $cart, CartProductRepository $cartProduct, CustomerRepository $customer) { + //Cookie expiry limit in minutes + protected $minutes = 150; + + public function __construct(CartRepository $cart, CartProductRepository $cartProduct, CustomerRepository $customer ,$minutes = 150) { $this->customer = $customer; $this->cart = $cart; $this->cartProduct = $cartProduct; + + $this->minutes = $minutes; } public function guestUnitAdd($id) { + //empty array for storing the products $products = array(); - $minutes = 150; - if(Cookie::has('cart_session_id')) { + //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); - // dd('Cookie = ',$cart_session_id, 'Session = ', session()->get('cart_session_id'), 'DB = ', $current_cart->session_id); - + //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 $this->repairCart($cart_session_id, $id); } - + //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_products = array(); $current_cart_products = $this->cart->getProducts($current_cart_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; if($product_id == $id) { + //create status code to communicate with session flash session()->flash('error', 'Item Already In Cart'); + //remove this its temporary dump('Item Already In Cart'); return redirect()->back(); } } + //cart data being attached to the instace. $cart_data = $this->cart->attach($current_cart_id, $id, 1); + //getting the products after being attached to cart instance $cart_products = $this->cart->getProducts($current_cart_id); + //storing the information in session. session()->put('cart_data', [$current_cart, $cart_products]); - session()->flash('Success', 'Item Added In Cart'); + session()->flash('Success', 'Item Added To Cart Successfully'); dump($cart_products); + //return the control to the controller return redirect()->back(); } else { - //repair the cart + //repair the cart, will remake the session + //and add the product in the new cart instance. $this->repairCart($cart_session_id, $id); } } else { - //create a new cart instance. + //function call $this->createNewCart($id); } } @@ -112,23 +126,20 @@ class Cart { * Session. * * @return mixed - */ + */ public function createNewCart($id) { - $minutes = 120; $fresh_cart_session_id = session()->getId(); - Cookie::queue('cart_session_id', $fresh_cart_session_id, $minutes); - - $cart_session_id = $this->makeCartSession($fresh_cart_session_id); - $data['session_id'] = $fresh_cart_session_id; $data['channel_id'] = core()->getCurrentChannel()->id; if($cart = $this->cart->create($data)) { + $this->makeCartSession($fresh_cart_session_id); + $new_cart_id = $cart->id ?? $cart['id']; $cart_product['product_id'] = $id; @@ -141,7 +152,7 @@ class Cart { session()->put('cart_data', [$cart, $cart_product]); - session()->flash('success', 'Product Added To Cart'); + session()->flash('success', 'Item Added To Cart Successfully'); return redirect()->back(); } @@ -156,9 +167,12 @@ class Cart { * cart. */ public function makeCartSession($cart_session_id) { - session()->put('cart_session_id', $cart_session_id); - return session()->get('cart_session_id'); + $fresh_cart_session_id = $cart_session_id; + + Cookie::queue('cart_session_id', $fresh_cart_session_id, $this->minutes); + + session()->put('cart_session_id', $fresh_cart_session_id); } @@ -170,8 +184,7 @@ class Cart { * * @return mixed */ - - public function repairCart($cart_session_id, $product_id) { + public function repairCart($cart_session_id ="null", $product_id = 0) { if($cart_session_id == session()->get('cart_session_id')) { $data['session_id'] = $cart_session_id; @@ -184,7 +197,7 @@ class Cart { $this->cart->attach($cart_id, $product_id, 1); - session()->flash('success', 'Product Added In Cart'); + session()->flash('success', 'Item Added To Cart Successfully'); return redirect()->back(); @@ -212,8 +225,8 @@ class Cart { public function guestUnitRemove($id) { //remove the products here - if(Cookie::has('session_c')) { - $products = unserialize(Cookie::get('session_c')); + if(Cookie::has('session_cart_id')) { + $products = unserialize(Cookie::get('session_cart_id')); foreach($products as $key => $value) { if($value == $id) { @@ -221,7 +234,7 @@ class Cart { array_push($products, $id); - Cookie::queue('session_c', serialize($products)); + Cookie::queue('session_cart_id', serialize($products)); return redirect()->back(); } @@ -239,46 +252,80 @@ class Cart { $products = array(); - // $customerLoggedIn = auth()->guard('customer')->check(); - - // //customer is authenticated - // if ($customerLoggedIn) { - //assuming that there is data in cookie and customer's cart also. + if(!auth()->guard('customer')->check()) { + throw new \Exception('This function is protected for auth customers only.'); + } $data['customer_id'] = auth()->guard('customer')->user()->id; $data['channel_id'] = core()->getCurrentChannel()->id; - $customerCart = $this->cart->findOneByField('customer_id', $data['customer_id']); + $customer_cart = $this->cart->findOneByField('customer_id', $data['customer_id']); //if there are products already in cart of that customer. - $customerCartId = $customerCart->id ?? $customerCart['id']; + $customer_cart_id = $customer_cart->id ?? $customer_cart['id']; - $customerCartProducts = $this->cart->getProducts($customerCartId); + /** + * Check if their any + * instance of current + * customer in the cart + * table. + */ + if(isset($customer_cart)) { + $customer_cart_products = $this->cart->getProducts($customer_cart_id); - if (isset($customerCartProducts)) { + if (isset($customer_cart_products)) { - foreach ($customerCartProducts as $previousCartProduct) { + foreach ($customer_cart_products as $customer_cart_product) { + if($customer_cart_product->id == $id) { + dump('Item already exists in cart'); - if($previousCartProduct->id == $id) { - dd('product already exists in cart'); + session()->flash('error', 'Item already exists in cart'); - session()->flash('error', 'Product already exists in cart'); + return redirect()->back(); - return redirect()->back(); + //maybe increase the quantity in here + } } + //add the product in the cart + + $this->cart->attach($customer_cart_id, $id, 1); + + session()->flash('success', 'Item Added To Cart Successfully'); + + return redirect()->back(); + } else { + $this->cart->destroy($customer_cart_id); + + session()->flash('error', 'Try Adding The Item Again'); + + dd('cart instance without any product found, delete it and create a new one for the current product id'); + + return redirect()->back(); } - //add the product in the cart + } else { + /** + * this will work + * for logged in users + * and they do not have + * any cart instance + * found in the database. + */ - $product['product_id'] = $id; + if($new_cart = $this->cart->create($data)) { + $new_cart_id = $new_cart->id ?? $new_cart['id']; - $product['quantity'] = 1; + $this->cart->attach($new_cart_id, $id, 1); - $product['cart_id'] = $customerCartId; + session()->flash('success', 'Item Added To Cart Successfully'); - $this->cartProduct->create($product); + return redirect()->back(); - return redirect()->back(); + } else { + session()->flash('error', 'Cannot Add Item in Cart'); + + return redirect()->back(); + } } } @@ -301,7 +348,6 @@ class Cart { */ public function mergeCart() { - //considering cookie as a source of truth. if(Cookie::has('cart_session_id')) { /* diff --git a/packages/Webkul/Cart/src/Http/ViewComposers/CartComposer.php b/packages/Webkul/Cart/src/Http/ViewComposers/CartComposer.php new file mode 100644 index 000000000..a216c1d5c --- /dev/null +++ b/packages/Webkul/Cart/src/Http/ViewComposers/CartComposer.php @@ -0,0 +1,59 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ + +class CartComposer +{ + + /** + * The cart implementation + * for shop bundle's navigation + * menu + */ + protected $cart; + + /** + * Bind data to the view. + * + * @param View $view + * @return void + */ + public function __construct(CartRepository $cart) { + $this->cart = $cart; + } + + 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']); + + // dd($cart_products); + + $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']); + + $view->with('cart', $cart_products); + } + } + } +} diff --git a/packages/Webkul/Cart/src/Models/Cart.php b/packages/Webkul/Cart/src/Models/Cart.php index 20f376f67..f1591cdb4 100644 --- a/packages/Webkul/Cart/src/Models/Cart.php +++ b/packages/Webkul/Cart/src/Models/Cart.php @@ -10,11 +10,12 @@ class Cart extends Model { protected $table = 'cart'; - protected $fillable = ['customer_id','session_id','channel_id','coupon_code','is_gift']; + protected $fillable = ['customer_id', 'session_id', 'channel_id', 'coupon_code', 'is_gift']; protected $hidden = ['coupon_code']; public function with_products() { + return $this->belongsToMany(Product::class, 'cart_products')->withPivot('id', 'product_id','quantity', 'cart_id'); } } diff --git a/packages/Webkul/Cart/src/Providers/CartServiceProvider.php b/packages/Webkul/Cart/src/Providers/CartServiceProvider.php index f05e1cb39..ac8fc304b 100644 --- a/packages/Webkul/Cart/src/Providers/CartServiceProvider.php +++ b/packages/Webkul/Cart/src/Providers/CartServiceProvider.php @@ -9,6 +9,7 @@ use Illuminate\Foundation\AliasLoader; use Webkul\User\Http\Middleware\RedirectIfNotAdmin; use Webkul\Customer\Http\Middleware\RedirectIfNotCustomer; use Webkul\Cart\Facades\Cart; +use Webkul\Cart\Providers\ComposerServiceProvider; class CartServiceProvider extends ServiceProvider { @@ -19,9 +20,9 @@ class CartServiceProvider extends ServiceProvider $router->aliasMiddleware('admin', RedirectIfNotAdmin::class); - // $router->aliasMiddleware('customer', RedirectIfNotCustomer::class); + $router->aliasMiddleware('customer', RedirectIfNotCustomer::class); - $this->register(EventServiceProvider::class); + $this->app->register(ComposerServiceProvider::class); } /** @@ -41,6 +42,9 @@ class CartServiceProvider extends ServiceProvider */ protected function registerFacades() { + + //to make the cart facade and bind the + //alias to the class needed to be called. $loader = AliasLoader::getInstance(); $loader->alias('cart', Cart::class); diff --git a/packages/Webkul/Cart/src/Providers/ComposerServiceProvider.php b/packages/Webkul/Cart/src/Providers/ComposerServiceProvider.php new file mode 100644 index 000000000..3f62d51c7 --- /dev/null +++ b/packages/Webkul/Cart/src/Providers/ComposerServiceProvider.php @@ -0,0 +1,32 @@ + ['web']], function () { - Route::get('/test', 'Webkul\Cart\Http\Controllers\CartController@test'); - Route::get('/', 'Webkul\Shop\Http\Controllers\HomeController@index')->defaults('_config', [ 'view' => 'shop::home.index' ])->name('store.home'); @@ -29,15 +27,8 @@ Route::group(['middleware' => ['web']], function () { Route::post('product/remove/{id}', 'Webkul\Cart\Http\Controllers\CartController@remove')->name('cart.remove'); - // Route::post('product/customer/cart/add/{id}', 'Webkul\Cart\Http\Controllers\CartController@add')->name('cart.customer.add'); - - // Route::post('product/customer/cart/remove/{id}', 'Webkul\Cart\Http\Controllers\CartController@remove')->name('cart.customer.remove'); - - Route::get('product/customer/cart/merge', 'Webkul\Cart\Http\Controllers\CartController@handleMerge')->name('cart.merge'); - //Routes for product cart ends - // Product Review routes Route::get('/reviews/{slug}/{id}', 'Webkul\Shop\Http\Controllers\ReviewController@show')->defaults('_config', [ 'view' => 'shop::products.reviews.index' @@ -55,13 +46,6 @@ Route::group(['middleware' => ['web']], function () { 'redirect' => 'admin.reviews.index' ])->name('admin.reviews.store'); - // Route::post('/reviews/create/{slug}', 'Webkul\Core\Http\Controllers\ReviewController@store')->defaults('_config', [ - // 'redirect' => 'admin.reviews.index' - // ])->name('admin.reviews.store'); - - - // Route::view('/products/{slug}', 'shop::store.product.details.index'); - Route::view('/cart', 'shop::store.product.view.cart.index'); //customer routes starts here Route::prefix('customer')->group(function () { @@ -92,12 +76,6 @@ Route::group(['middleware' => ['web']], function () { 'redirect' => 'customer.session.index' ])->name('customer.session.destroy'); - Route::view('/cart', 'shop::store.product.cart.cart.index')->name('customer.cart'); - - Route::view('/product', 'shop::store.product.details.home.index')->name('customer.product'); - - Route::view('/product/review', 'shop::store.product.review.index')->name('customer.product.review'); - //customer account Route::prefix('account')->group(function () { diff --git a/packages/Webkul/Shop/src/Resources/assets/js/app.js b/packages/Webkul/Shop/src/Resources/assets/js/app.js index 320d65719..9c192b635 100644 --- a/packages/Webkul/Shop/src/Resources/assets/js/app.js +++ b/packages/Webkul/Shop/src/Resources/assets/js/app.js @@ -8,6 +8,7 @@ Vue.component("category-nav", require("./components/category-nav.vue")); Vue.component("category-item", require("./components/category-item.vue")); Vue.component("image-slider", require("./components/image-slider.vue")); Vue.component("vue-slider", require("vue-slider-component")); +Vue.component("cart-dropdown", require("./components/cart-dropdown.vue")); $(document).ready(function () { @@ -50,6 +51,7 @@ $(document).ready(function () { const flashes = this.$refs.flashes; flashMessages.forEach(function (flash) { + console.log(flash); flashes.addFlash(flash); }, this); }, 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 new file mode 100644 index 000000000..9b27c8634 --- /dev/null +++ b/packages/Webkul/Shop/src/Resources/assets/js/components/cart-dropdown.vue @@ -0,0 +1,156 @@ + + + \ No newline at end of file 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 4ff3508ad..e38dc943f 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 @@ -29,7 +29,6 @@ export default { computed: { haveChildren() { - console.log(this.item); return this.item.children.length ? true : false; } } diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss index 799e0760b..f3689ae9b 100644 --- a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss +++ b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss @@ -21,6 +21,7 @@ body { .header { margin-top: 16px; margin-bottom: 21px; + user-select: none; .header-top { margin-bottom: 16px; @@ -293,7 +294,6 @@ body { .nav li li:hover > a:first-child:nth-last-child(2):before { right: 10px; } - } } @@ -310,7 +310,7 @@ body { .header-top { margin-bottom: 16px; display: flex; - max-width: 92%; + // max-width: 92%; width: 100%; margin-left: auto; margin-right: auto; @@ -482,7 +482,7 @@ body { .header-top { margin-bottom: 16px; display: flex; - max-width: 92%; + // max-width: 92%; width: 100%; margin-left: auto; margin-right: auto; @@ -1007,6 +1007,27 @@ section.slider-block { } } +//responsive for main-container-wrapper + +@media all and (max-width: 480px) { + .main-container-wrapper { + width: 100% !important; + margin-left: auto; + margin-right: auto; + } +} + +@media all and (min-width: 481px) and (max-width: 920px) { + .main-container-wrapper { + width: 90%; + margin-left: auto; + margin-right: auto; + } +} + + + + .product-price { font-size: 16px; margin-bottom: 14px; diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/icons.scss b/packages/Webkul/Shop/src/Resources/assets/sass/icons.scss index e8ce2979e..762f456ae 100644 --- a/packages/Webkul/Shop/src/Resources/assets/sass/icons.scss +++ b/packages/Webkul/Shop/src/Resources/assets/sass/icons.scss @@ -3,7 +3,7 @@ background-size: cover; } -.dropdown-right-icon{ +.dropdown-right-icon { background-image:URL('../images/icon-dropdown-left.svg'); width: 8px; height: 8px; @@ -11,6 +11,14 @@ margin-bottom: 2px; } +.icon-menu-close { + background-image:URL('../images/icon-menu-close.svg'); + width: 8px; + height: 8px; + margin-left:auto; + margin-bottom: 2px; +} + .grid-view-icon { background-image:URL('../images/icon-grid-view.svg'); width: 24px; 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 d15ab5888..0fdee9e33 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 @@ -1,7 +1,5 @@ @push('scripts') - - - @endpush \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/views/products/view.blade.php b/packages/Webkul/Shop/src/Resources/views/products/view.blade.php index 1f53659fc..feaa5bd83 100644 --- a/packages/Webkul/Shop/src/Resources/views/products/view.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/view.blade.php @@ -8,7 +8,6 @@
- {{-- {{ dd(session()->getId()) }} --}}
@csrf() diff --git a/packages/Webkul/Shop/src/Resources/views/products/view/gallery.blade.php b/packages/Webkul/Shop/src/Resources/views/products/view/gallery.blade.php index 54c605929..e5ddae8a6 100644 --- a/packages/Webkul/Shop/src/Resources/views/products/view/gallery.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/view/gallery.blade.php @@ -61,7 +61,6 @@ }, created () { - console.log(this.images[0]) this.changeImage(this.images[0]) this.prepareThumbs() diff --git a/packages/Webkul/Ui/src/Resources/assets/js/components/flash-wrapper.vue b/packages/Webkul/Ui/src/Resources/assets/js/components/flash-wrapper.vue index f22019967..902807869 100644 --- a/packages/Webkul/Ui/src/Resources/assets/js/components/flash-wrapper.vue +++ b/packages/Webkul/Ui/src/Resources/assets/js/components/flash-wrapper.vue @@ -5,7 +5,7 @@ class='alert-wrapper' > {!! $column->sorting() !!} @endif @endforeach - @if(isset($attribute_columns)) + {{-- @if(isset($attribute_columns)) @foreach($attribute_columns as $key => $value) {{ $value }} @endforeach - @endif + @endif --}} Actions @@ -131,11 +131,11 @@ {!! $column->render($result) !!} @endforeach - @if(isset($attribute_columns)) + {{-- @if(isset($attribute_columns)) @foreach ($attribute_columns as $atc) {{ $result->{$atc} }} @endforeach - @endif + @endif --}} @foreach($actions as $action) diff --git a/packages/Webkul/Ui/webpack.mix.js b/packages/Webkul/Ui/webpack.mix.js index 32804fbcc..4fa81616a 100644 --- a/packages/Webkul/Ui/webpack.mix.js +++ b/packages/Webkul/Ui/webpack.mix.js @@ -14,7 +14,7 @@ mix.js( ], "js/ui.js" ) - // .copy(__dirname + "/src/Resources/assets/images", publicPath + "/images") + .copy(__dirname + "/src/Resources/assets/images", publicPath + "/images") .sass(__dirname + "/src/Resources/assets/sass/app.scss", "css/ui.css") .options({ processCssUrls: false diff --git a/public/themes/default/assets/css/shop.css b/public/themes/default/assets/css/shop.css index b674c2995..da3cdc0de 100644 --- a/public/themes/default/assets/css/shop.css +++ b/public/themes/default/assets/css/shop.css @@ -11,6 +11,14 @@ margin-bottom: 2px; } +.icon-menu-close { + background-image: URL("../images/icon-menu-close.svg"); + width: 8px; + height: 8px; + margin-left: auto; + margin-bottom: 2px; +} + .grid-view-icon { background-image: URL("../images/icon-grid-view.svg"); width: 24px; @@ -40,6 +48,10 @@ body { .header { margin-top: 16px; margin-bottom: 21px; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; } .header .header-top { @@ -380,7 +392,6 @@ body { display: -webkit-box; display: -ms-flexbox; display: flex; - max-width: 92%; width: 100%; margin-left: auto; margin-right: auto; @@ -533,7 +544,6 @@ body { display: -webkit-box; display: -ms-flexbox; display: flex; - max-width: 92%; width: 100%; margin-left: auto; margin-right: auto; @@ -1057,6 +1067,22 @@ section.slider-block div.slider-content div.slider-control .light-right-icon { width: 100%; } +@media all and (max-width: 480px) { + .main-container-wrapper { + width: 100% !important; + margin-left: auto; + margin-right: auto; + } +} + +@media all and (min-width: 481px) and (max-width: 920px) { + .main-container-wrapper { + width: 90%; + margin-left: auto; + margin-right: auto; + } +} + .product-price { font-size: 16px; margin-bottom: 14px; diff --git a/public/themes/default/assets/js/shop.js b/public/themes/default/assets/js/shop.js index 92989e592..ea917445b 100644 --- a/public/themes/default/assets/js/shop.js +++ b/public/themes/default/assets/js/shop.js @@ -221,6 +221,7 @@ Vue.component("category-nav", __webpack_require__(10)); Vue.component("category-item", __webpack_require__(13)); Vue.component("image-slider", __webpack_require__(16)); Vue.component("vue-slider", __webpack_require__(24)); +Vue.component("cart-dropdown", __webpack_require__(29)); $(document).ready(function () { @@ -263,6 +264,7 @@ $(document).ready(function () { var flashes = this.$refs.flashes; flashMessages.forEach(function (flash) { + console.log(flash); flashes.addFlash(flash); }, this); }, @@ -29279,7 +29281,6 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); computed: { haveChildren: function haveChildren() { - console.log(this.item); return this.item.children.length ? true : false; } } @@ -29920,5 +29921,267 @@ if (false) { // removed by extract-text-webpack-plugin +/***/ }), +/* 26 */, +/* 27 */, +/* 28 */, +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + +var disposed = false +function injectStyle (ssrContext) { + if (disposed) return + __webpack_require__(32) +} +var normalizeComponent = __webpack_require__(1) +/* script */ +var __vue_script__ = __webpack_require__(30) +/* template */ +var __vue_template__ = __webpack_require__(31) +/* template functional */ +var __vue_template_functional__ = false +/* styles */ +var __vue_styles__ = injectStyle +/* scopeId */ +var __vue_scopeId__ = null +/* moduleIdentifier (server only) */ +var __vue_module_identifier__ = null +var Component = normalizeComponent( + __vue_script__, + __vue_template__, + __vue_template_functional__, + __vue_styles__, + __vue_scopeId__, + __vue_module_identifier__ +) +Component.options.__file = "src/Resources/assets/js/components/cart-dropdown.vue" + +/* hot reload */ +if (false) {(function () { + var hotAPI = require("vue-hot-reload-api") + hotAPI.install(require("vue"), false) + if (!hotAPI.compatible) return + module.hot.accept() + if (!module.hot.data) { + hotAPI.createRecord("data-v-0f947e82", Component.options) + } else { + hotAPI.reload("data-v-0f947e82", Component.options) + } + module.hot.dispose(function (data) { + disposed = true + }) +})()} + +module.exports = Component.exports + + +/***/ }), +/* 30 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// + + +// define the item component + +/* harmony default export */ __webpack_exports__["default"] = ({ + props: { + items: Array + }, + + data: function data() { + return { + toggle: true, + totalitems: 0, + cart_items: [] + }; + }, + + + computed: { + makeDropdown: function makeDropdown() {} + }, + + mounted: function mounted() { + if (this.items != undefined) this.initializeDropdown(); + }, + + methods: { + dropOrHide: function dropOrHide() { + if (this.toggle == false) { + this.toggle = true; + } else { + this.toggle = false; + } + }, + + initializeDropdown: function initializeDropdown() { + this.totalitems = this.items.length; + } + } +}); + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + +var render = function() { + var _vm = this + var _h = _vm.$createElement + var _c = _vm._self._c || _h + return _c("div", [ + _c("ul", { staticClass: "cart-dropdown", on: { click: _vm.dropOrHide } }, [ + _c("li", { staticClass: "cart-summary" }, [ + _c("span", { staticClass: "icon cart-icon" }), + _vm._v(" "), + _c("span", { staticClass: "cart" }, [ + _vm.totalitems > 0 + ? _c("span", { staticClass: "cart-count" }, [ + _vm._v(_vm._s(_vm.totalitems)) + ]) + : _vm._e(), + _vm._v("Products") + ]), + _vm._v(" "), + _c("span", { staticClass: "icon arrow-down-icon" }) + ]) + ]), + _vm._v(" "), + _c("div", { staticClass: "dropdown-cart", class: { show: _vm.toggle } }, [ + _c("div", { staticClass: "dropdown-header" }, [ + _c("p", { staticClass: "heading" }, [_vm._v("Cart Subtotal - $80")]), + _vm._v(" "), + _c("i", { + staticClass: "icon icon-menu-close", + on: { click: _vm.dropOrHide } + }) + ]), + _vm._v(" "), + _vm._m(0), + _vm._v(" "), + _vm._m(1) + ]) + ]) +} +var staticRenderFns = [ + function() { + var _vm = this + var _h = _vm.$createElement + var _c = _vm._self._c || _h + return _c("div", { staticClass: "dropdown-content" }, [ + _c("div", { staticClass: "item" }, [ + _c("div", { staticClass: "item-image" }, [_c("img")]), + _vm._v(" "), + _c("div", { staticClass: "item-details" }, [ + _c("div", { staticClass: "item-name" }, [_vm._v("Some Item Name")]), + _vm._v(" "), + _c("div", { staticClass: "item-price" }, [_vm._v("$ Some Price")]), + _vm._v(" "), + _c("div", { staticClass: "item-qty" }, [_vm._v("Some Quantity")]) + ]) + ]) + ]) + }, + function() { + var _vm = this + var _h = _vm.$createElement + var _c = _vm._self._c || _h + return _c("div", { staticClass: "dropdown-footer" }, [ + _c("a", { attrs: { href: "/" } }, [_vm._v("View Shopping Cart")]), + _vm._v(" "), + _c("button", { staticClass: "btn btn-primary btn-lg" }, [ + _vm._v("CHECKOUT") + ]) + ]) + } +] +render._withStripped = true +module.exports = { render: render, staticRenderFns: staticRenderFns } +if (false) { + module.hot.accept() + if (module.hot.data) { + require("vue-hot-reload-api") .rerender("data-v-0f947e82", module.exports) + } +} + +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + +// style-loader: Adds some css to the DOM by adding a