本文整理汇总了PHP中Cart::getCart方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart::getCart方法的具体用法?PHP Cart::getCart怎么用?PHP Cart::getCart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart
的用法示例。
在下文中一共展示了Cart::getCart方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
header("Content-type: text/html; charset=" . $this->encoding);
$this->model = new Model();
$this->safebox = Safebox::getInstance();
$this->user = $this->safebox->get('user');
if ($this->user == null) {
$this->user = Common::autoLoginUserInfo();
$this->safebox->set('user', $this->user);
}
$category = Category::getInstance();
$this->category = $category->getCategory();
$cart = Cart::getCart();
$action = Req::args("act");
switch ($action) {
case 'order_detail':
$action = 'order';
break;
case 'refund_detail':
$action = 'refund';
break;
}
$this->assign("actionId", $action);
$this->assign("cart", $cart->all());
$this->assign("cart_num", $cart->getNum());
$this->assign("sidebar", $this->sidebar);
$this->assign("category", $this->category);
$this->assign("seo_title", "用户中心");
}
示例2: init
public function init()
{
header("Content-type: text/html; charset=" . $this->encoding);
$this->model = new Model();
$this->safebox = Safebox::getInstance();
$this->user = $this->safebox->get('user');
$category = Category::getInstance();
$this->category = $category->getCategory();
$cart = Cart::getCart();
$this->assign("cart_num", $cart->getNum());
$this->assign("cart", $cart->all());
$this->assign("category", $this->category);
}
示例3: addToCart
function addToCart()
{
$result = $this->Cart->Product->findById($this->p);
if (empty($result)) {
$this->Session->setFlash('This product was not found!');
$this->redirect(array('action' => 'index'));
} else {
if ($result['Product']['pd_qty'] <= 0) {
$this->Session->setFlash('The product you requested is out of stock!');
$this->redirect(array('action' => 'index'));
}
}
//ce je user loginan se uporablja userov ID
if ($this->Auth->user()) {
$sessionData = $this->Cart->getCart($this->p, $this->sid, $this->Session->read('Auth.User.id'));
if (empty($sessionData)) {
$this->Cart->addToCart($this->p, $this->sid, $this->Session->read('Auth.User.id'));
$this->Session->setFlash('Product added to cart! -> through user ID / inserted');
} else {
$this->Cart->updateCart($this->p, $this->sid, $this->Session->read('Auth.User.id'));
$this->Session->setFlash('Product added to cart! -> through session ID / updated');
}
//ce user ni prijavljen se uporablja sejni ID
} else {
$sessionData = $this->Cart->getCart($this->p, $this->sid);
if (empty($sessionData)) {
$this->Cart->addToCart($this->p, $this->sid);
$this->Session->setFlash('Product added to cart! -> through session ID / inserted');
} else {
$this->Cart->updateCart($this->p, $this->sid);
$this->Session->setFlash('Product added to cart! -> through session ID / updated');
}
}
$this->Cart->cleanUp();
$this->redirect(array('controller' => 'carts', 'action' => "index/c:{$this->c}/p:{$this->p}"));
}
示例4: get
if (page('shop')->mailing_address()->bool() and get('payer_address')) {
// Address provided, we're good.
$valid = true;
} else {
// No address provided.
$valid = false;
}
}
} else {
// No name or email provided.
$valid = false;
}
if ($valid) {
// Save customer details to the transaction
try {
$txn->update(['payer-name' => get('payer_name'), 'payer-email' => get('payer_email'), 'payer-address' => get('payer_address')], $site->defaultLanguage()->code());
} catch (Exception $e) {
// Update failed
snippet('mail.order.update.error', ['txn' => $txn, 'payment_status' => $txn->status(), 'payer_name' => get('payer_name'), 'payer_email' => get('payer_email'), 'payer_address' => get('payer_address')]);
return false;
}
// Empty the cart
$cart = Cart::getCart();
$cart->emptyItems();
// Redirect to orders page
go('shop/orders?txn_id=' . $txn->txn_id());
}
}
// Form is invalid or hasn't been submitted yet
return ['txn' => $txn, 'payer_name' => $payer_name, 'payer_email' => $payer_email, 'payer_address' => $payer_address];
};
示例5: page
page('shop/orders/' . get('update_id'))->update(['status' => 'paid']);
} catch (Exception $e) {
echo $e->getMessage();
}
}
// Role-based filters
if (get('txn_id') != '') {
// If single transaction ID passed, show just that one order
$orders = $page->children()->sortBy('txn_date', 'desc')->filterBy('txn_id', get('txn_id'));
} else {
if ($user and $user->role() == 'admin') {
// If admin, show all orders
$orders = $page->children()->sortBy('txn_date', 'desc');
} else {
if ($user) {
// If logged in, show this user's orders
$orders = $page->children()->sortBy('txn_date', 'desc')->filterBy('payer_email', $user->email());
} else {
// If not logged in, don't show orders
$orders = false;
}
}
}
// Status filters
if (get('status')) {
$orders = $orders->filter(function ($order) {
return in_array($order->status(), get('status'));
});
}
return ['user' => $site->user(), 'cart' => Cart::getCart(), 'orders' => $orders];
};
示例6: order_act
//.........这里部分代码省略.........
$data['payable_freight'] = $payable_freight;
$data['real_freight'] = $real_freight;
$data['create_time'] = date('Y-m-d H:i:s');
$data['user_remark'] = $user_remark;
$data['is_invoice'] = $is_invoice;
if ($is_invoice == 1) {
$data['invoice_title'] = $invoice_type . ':' . $invoice_title;
} else {
$data['invoice_title'] = '';
}
$data['taxes'] = $tax_fee;
$data['discount_amount'] = $discount_amount;
$data['order_amount'] = $order_amount;
$data['real_amount'] = $real_amount;
$data['point'] = $point;
$data['type'] = $order_type;
// type -> order_type
$data['voucher_id'] = $voucher_id;
$data['voucher'] = serialize($voucher);
//var_dump($order_products);exit();
// TODO SKM 写入订单数据
$order_id = $model->table("order")->data($data)->insert();
//写入订单商品
// 单品 加入订单详情表
foreach ($order_products as $goods_id => $products) {
foreach ($products as $product_id => $item) {
$tem_data = array('order_id' => '', 'goods_id' => '', 'product_id' => '', 'goods_name' => '', 'goods_price' => '', 'real_price' => '', 'goods_nums' => '', 'tax_code' => '', 'spec' => '');
if (isset($item["order_type"])) {
if (is_array($item["order_type"])) {
if ($item["order_type"]["flash_sale"] == true) {
} elseif ($item["order_type"]["prom_series"] == true) {
$tem_data['prom_goods'] = serialize($item['prom_goods']);
} elseif ($item["order_type"]["prom_series"] == false && $item["order_type"]["prom_goods"] == true) {
$tem_data['prom_goods'] = serialize($item['prom_goods']);
} elseif ($item["order_type"]["bundling"] == true) {
}
}
}
$tem_data['order_id'] = $order_id;
$tem_data['goods_id'] = $item['goods_id'];
$tem_data['goods_no'] = $item['goods_no'];
$tem_data['product_id'] = $product_id;
$tem_data['goods_name'] = $item['name'];
$tem_data['goods_price'] = $item['sell_price'];
$tem_data['real_price'] = $item['real_price'];
$tem_data['goods_nums'] = $item['num'];
//$tem_data['goods_weight'] = $item['weight'];
$tem_data['tax_code'] = $item['tax_code'];
// todo SKM 跟税种相关
$tem_data['origin_country'] = $item['origin_country'];
$tem_data['spec'] = serialize($item['spec']);
$model->table("order_goods")->data($tem_data)->insert();
}
}
// 捆绑销售 加入订单详情表
if (!empty($cart_info[$ship_id]['bundling_list'])) {
$order_bundling = $cart_info[$ship_id]['bundling_list'];
foreach ($order_bundling as $item) {
$tem_data = array();
//$tem_data['prom_goods'] = serialize($item['prom_goods']);
foreach ($item as $key_bundling => $val_bundling) {
$bundling = $val_bundling;
$arr_products_id = explode('-', $key_bundling);
$str_products_ids = join(',', $arr_products_id);
$tem_data['order_id'] = $order_id;
$tem_data['goods_ids'] = $bundling["val"]['goods_id'];
$tem_data['products_ids'] = $str_products_ids;
// $tem_data['goods_price'] = $item['sell_price'];
$tem_data['title'] = $bundling["val"]['title'];
$tem_data['prom_type'] = "bundling";
$tem_data['bundling_id'] = $bundling["val"]['id'];
$tem_data['real_price'] = $bundling['val']['price'];
$tem_data['goods_nums'] = $bundling['num'];
// $tem_data['goods_weight'] = $item['weight'];
// $tem_data['spec'] = serialize($item['spec']);
$model->table("order_goods")->data($tem_data)->insert();
}
}
}
//优惠券锁死
if (!empty($voucher)) {
$model->table("voucher")->where("id={$voucher_id} and user_id=" . $this->user['id'])->data(array('status' => 2))->update();
}
//清空购物车与表单缓存
if ($order_type == 0) {
$this->cart_inst = Cart::getCart();
$this->cart_inst->clearShip($ship_id);
// 清空 ship_id 购物车 分库位置
//$cart->clear();
Session::clear("order_status");
}
$this->redirect("/simple/order_status/order_id/{$order_id}");
} else {
$msg = array('type' => 'fail', 'msg' => '非法提交订单!');
$this->redirect('/index/msg', false, $msg);
}
} else {
$this->redirect("login");
}
}
示例7: order
/**
* The function posts order.
*
* @access public
* @return string The JSON response.
*/
public function order()
{
$Cart = Cart::getCart();
$Order = $Cart->getOrder();
$Order->Type = Order::STANDARD;
return $this->postOrder($Order, $Cart);
}
示例8: User
<?php
// Ensure source code is readable:
if (isset($_GET['source'])) {
highlight_file($_SERVER['SCRIPT_FILENAME']);
exit;
}
// Call on required codes:
require 'model.php';
require 'view.php';
// Begin calling classes:
$user = new User();
if ($user->validate()) {
$user->getRight();
$cart = new Cart($_SESSION['data'], $user->session);
if ($cart->getCart()) {
$cartPanel = new cartView($cart);
$cartPanel->output();
}
if (in_array("admin", $user->rights)) {
$inventory = new Inventory($user->session);
$inventoryPanel = new InventoryView($inventory->getInventory());
$inventoryPanel->output();
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Log-In Page</title>
<meta charset="utf-8">
示例9: htmlCartAddress
/**
* The function returns address (contact) block for order.
*
* @access public
* @return string The HTML code.
*/
public function htmlCartAddress()
{
return $this->includeLayout('view/cart/contact.html', array('Cart' => Cart::getCart()));
}
示例10: checkProductTax_p2
private function checkProductTax_p2($ship_id, $tax_amount)
{
$cart = Cart::getCart();
$ret = $cart->getTaxAmountByShip($ship_id);
if ($ret['status'] == 1) {
$tax_amount = $ret['data'] + $tax_amount;
}
return $tax_amount;
}