public function update(Requests\CartRequest $request, $id)
 {
     $qtd = $request->get("qtd");
     $cart = $this->getCart();
     $cart->setQtd($id, $qtd);
     Session::set('cart', $cart);
     return redirect()->route('store.cart');
 }
 public function update(CartRequest $request, $id, Session $session)
 {
     $data = $request->all();
     $cart = $this->getCart($session);
     $product = $this->productsRepository->find($id);
     $cart->update($id, $product->name, $product->price, $data['qtd']);
     if ($data['qtd'] == 0) {
         $cart->remove($id);
     }
     $session::set('cart', $cart);
     return redirect()->route('cart');
 }
 public function update(\CodeCommerce\Http\Requests\CartRequest $request, $id, Session $session)
 {
     $data = $request->all();
     $cart = $this->getCart($session);
     $product = Product::find($id);
     $cart->update($id, $product->name, $product->price, $data['qtd']);
     if ($data['qtd'] == 0) {
         $cart->remove($id);
     }
     $session::set('cart', $cart);
     return redirect()->route('cart');
 }
Пример #4
0
 public function updateItem(Requests\CartRequest $cartRequest)
 {
     $input = $cartRequest->all();
     $id = $input['id'];
     $quantity = $input['quantity'];
     $cart = $this->getCart();
     $product = Product::find($id);
     $cart->addMoreThanOneQuantity($id, $product->name, $product->price, $quantity);
     Session::set('cart', $cart);
     $subTotal = $product->price * $cart->all()[$id]['qtd'];
     $items = $cart->all();
     return response()->json(['subTotal' => $subTotal, 'total' => $cart->getTotal(), 'qtd' => $items[$id]['qtd']]);
 }