public function testCartCanGet() { Cart::add(1, 'test', 1, 10.0, array('size' => 'L')); $rowId = Cart::content()->first()->rowid; $row = Cart::get($rowId); $this->assertEquals($row->id, 1); $this->assertEquals($row->name, 'test'); $this->assertEquals($row->qty, 1); $this->assertEquals($row->price, 10.0); $this->assertInstanceOf('Gloudemans\\Shoppingcart\\CartRowCollection', $row); $this->assertInstanceOf('Gloudemans\\Shoppingcart\\CartRowOptionsCollection', $row->options); $this->assertEquals($row, Cart::content()->first()); $this->assertInstanceOf('Gloudemans\\Shoppingcart\\CartCollection', Cart::content()); }
public function minusCart($deal_id) { $cart = \Cart::get($deal_id); $newQuantity = --$cart->quantity; if ($newQuantity <= 0) { \Cart::remove($deal_id); } else { \Cart::update($deal_id, ['quantity' => $newQuantity]); } return redirect('/gio-hang'); }
public function itemsSum() { $cart = Cart::get($this->id); $sums = []; foreach ($cart->cartItems as $cartItem) { if (!$cartItem->price) { continue; } $sums[$cartItem->price->currency_id] = isset($sums[$cartItem->price->currency_id]) ? $sums[$cartItem->price->currency_id] + $cartItem->price->price * $cartItem->count : $cartItem->price->price * $cartItem->count; } return new \Money\Sums($sums); }
/** * Get all cart items stored on the session * @return array */ public function get() { return $this->session->get('cart'); }
public function getRefresh() { if (Request::ajax()) { $item_id = Input::get('item_id'); $id = Input::get('id'); $qty = Input::get('qty'); $talla = Input::get('talla'); $color = Input::get('color'); $misc = Misc::where('item_talla', '=', $talla)->where('item_id', '=', $item_id)->where('item_color', '=', $color)->pluck('item_stock'); if ($misc < $qty) { return Response::json(array('type' => 'danger')); } $cart = Cart::get($id); Cart::update($id, $qty); $count = Cart::count(); $total = Cart::total(); return Response::json(array('type' => 'success', 'count' => $count, 'total' => $total, 'qty' => $cart->qty, 'id' => $cart->id, 'subtotal' => $cart->subtotal)); } }
public function updateQuantity() { $row_id = Input::get('row_id'); $qty = Input::get('qty'); Cart::update($row_id, $qty); $cart_row = Cart::get($row_id); $order_type = $cart_row->options->order_type; $sku = $cart_row->options->sku; $size = $cart_row->options->size; $sizes = explode("|", $size); $product = new VIImage(); $product->sku = $sku; $product->sizew = $sizes[0]; $product->sizeh = $sizes[1]; foreach ($cart_row->options->options as $option) { if ($option['type_key'] == 'depth') { $product->bleed = floatval($option['value']); } else { $product->{$option}['type_key'] = floatval($option['value']); } } $product->quantity = $qty; // echo '<pre>'; // print_r($product); // echo '</pre>'; $price = JTProduct::getPrice($product); Cart::update($row_id, ['price' => $price['sell_price']]); $cart_row = Cart::get($row_id); $cart_total = Cart::total(); $data = ['cart_row' => $cart_row, 'cart_total' => $cart_total]; if (Request::ajax()) { return Response::json(['result' => 'ok', 'data' => $data]); } return Redirect::route('order-cart'); }