本文整理汇总了PHP中Cart::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart::get方法的具体用法?PHP Cart::get怎么用?PHP Cart::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart
的用法示例。
在下文中一共展示了Cart::get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCartCanGet
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());
}
示例2: minusCart
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');
}
示例3: itemsSum
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);
}
示例4: get
/**
* Get all cart items stored on the session
* @return array
*/
public function get()
{
return $this->session->get('cart');
}
示例5: getRefresh
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));
}
}
示例6: updateQuantity
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');
}