本文整理汇总了PHP中Cart::getPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart::getPrice方法的具体用法?PHP Cart::getPrice怎么用?PHP Cart::getPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart
的用法示例。
在下文中一共展示了Cart::getPrice方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: change_quantity
public function change_quantity()
{
import('Think.ORG.Cart');
// 导入购物车类
$cart = new Cart();
$itemId = $this->_post('itemId', 'intval');
//商品ID
$quantity = $this->_post('quantity', 'intval');
//购买数量
$item = M('item')->field('goods_stock')->find($itemId);
if ($item['goods_stock'] < $quantity) {
$data = array('status' => 0, 'msg' => '该商品的库存不足');
} else {
$cart->modNum($itemId, $quantity);
$data = array('status' => 1, 'item' => $cart->getItem($itemId), 'sumPrice' => $cart->getPrice());
}
echo json_encode($data);
}
示例2: pay
public function pay()
{
if (IS_POST && count($_SESSION['cart']) > 0) {
$_SESSION['end'] = 0;
import('Think.ORG.Cart');
// 导入分页类
$cart = new Cart();
$user_address = M('user_address');
$item_order = M('item_order');
$order_detail = M('order_detail');
$item_goods = M('item');
$this->visitor->info['id'];
//用户ID
$this->visitor->info['username'];
//用户账号
//生成订单号
$dingdanhao = date("Y-m-dH-i-s");
$dingdanhao = str_replace("-", "", $dingdanhao);
$dingdanhao .= rand(1000, 2000);
$time = time();
//订单添加时间
$address_options = $this->_post('address_options', 'intval');
//地址 0:刚填的地址 大于0历史的地址
$shipping_id = $this->_post('shipping_id', 'intval');
//配送方式
$postscript = $this->_post('postscript', 'trim');
//卖家留言
if (!empty($postscript)) {
$data['note'] = $postscript;
}
if (empty($shipping_id)) {
$data['freetype'] = 0;
$data['order_sumPrice'] = $cart->getPrice();
} else {
$data['freetype'] = $shipping_id;
$data['freeprice'] = $this->getFree($shipping_id);
//取到运费
$data['order_sumPrice'] = $cart->getPrice() + $this->getFree($shipping_id);
//echo $cart->getPrice()+$this->getFree($shipping_id);exit;
}
$data['orderId'] = $dingdanhao;
//订单号
$data['add_time'] = $time;
//添加时间
$data['goods_sumPrice'] = $cart->getPrice();
//商品总额
$data['color'] = $cart->getColor();
//商品颜色
//$data['userId']=$this->visitor->info['id'];//用户ID
//$data['userName']=$this->visitor->info['username'];//用户名
$data['userId'] = '123';
//用户ID
$data['userName'] = '游客';
//用户名
if ($address_options == 0) {
$consignee = $this->_post('consignee', 'trim');
//真实姓名
$sheng = $this->_post('sheng', 'trim');
//省
$shi = $this->_post('shi', 'trim');
//市
$qu = $this->_post('qu', 'trim');
//区
$address = $this->_post('address', 'trim');
//详细地址
$phone_mob = $this->_post('phone_mob', 'trim');
//电话号码
$save_address = $this->_post('save_address', 'trim');
//是否保存地址
$data['address_name'] = $consignee;
//收货人姓名
$data['mobile'] = $phone_mob;
//电话号码
$data['address'] = $sheng . $shi . $qu . $address;
//地址
if ($save_address) {
$add_address['uid'] = $this->visitor->info['id'];
$add_address['consignee'] = $consignee;
$add_address['address'] = $address;
$add_address['mobile'] = $phone_mob;
$add_address['sheng'] = $sheng;
$add_address['shi'] = $shi;
$add_address['qu'] = $qu;
$user_address->data($add_address)->add();
}
} else {
$userId = $this->visitor->info['id'];
$address = $user_address->where("uid='{$userId}'")->find($address_options);
//取到地址
$data['address_name'] = $address['consignee'];
//收货人姓名
$data['mobile'] = $address['mobile'];
//电话号码
$data['address'] = $address['sheng'] . $address['shi'] . $address['qu'] . $address['address'];
//地址
}
if ($orderid = $item_order->data($data)->add()) {
$orders['orderId'] = $dingdanhao;
foreach ($_SESSION['cart'] as $item) {
$item_goods->where('id=' . $item['id'])->setDec('goods_stock', $item['num']);
//.........这里部分代码省略.........
示例3: pay
public function pay()
{
if (IS_POST && count($_SESSION['cart']) > 0) {
import('Think.ORG.Cart');
// 导入分页类
$cart = new Cart();
$user_address = M('user_address');
$item_order = M('item_order');
$order_detail = M('order_detail');
$item_goods = M('item');
$this->visitor->info['id'];
//用户ID
$this->visitor->info['username'];
//用户账号
//生成订单号
$dingdanhao = date("Y-m-dH-i-s");
$dingdanhao = str_replace("-", "", $dingdanhao);
$dingdanhao .= rand(1000, 2000);
$time = time();
//订单添加时间
$address_options = $this->_post('address_options', 'intval');
//地址 0:刚填的地址 大于0历史的地址
$shipping_id = $this->_post('shipping_id', 'intval');
//配送方式
$postscript = $this->_post('postscript', 'trim');
//卖家留言
if (!empty($postscript)) {
//卖家留言
$data['note'] = $postscript;
}
if (empty($shipping_id)) {
//卖家包邮
$data['freetype'] = 0;
$data['order_sumPrice'] = $cart->getPrice();
} else {
$data['freetype'] = $shipping_id;
$data['freeprice'] = $this->getFree($shipping_id);
//取到运费
$data['order_sumPrice'] = $cart->getPrice() + $this->getFree($shipping_id);
//echo $cart->getPrice()+$this->getFree($shipping_id);exit;
}
$data['orderId'] = $dingdanhao;
//订单号
$data['add_time'] = $time;
//添加时间
$data['goods_sumPrice'] = $cart->getPrice();
//商品总额
$data['userId'] = $this->visitor->info['id'];
//用户ID
$data['userName'] = $this->visitor->info['username'];
//用户名
if ($address_options == 0) {
$consignee = $this->_post('consignee', 'trim');
//真实姓名
$sheng = $this->_post('sheng', 'trim');
//省
$shi = $this->_post('shi', 'trim');
//市
$qu = $this->_post('qu', 'trim');
//区
$address = $this->_post('address', 'trim');
//详细地址
$phone_mob = $this->_post('phone_mob', 'trim');
//电话号码
$save_address = $this->_post('save_address', 'trim');
//是否保存地址
$data['address_name'] = $consignee;
//收货人姓名
$data['mobile'] = $phone_mob;
//电话号码
$data['address'] = $sheng . $shi . $qu . $address;
//地址
if ($save_address) {
//保存地址
$add_address['uid'] = $this->visitor->info['id'];
$add_address['consignee'] = $consignee;
$add_address['address'] = $address;
$add_address['mobile'] = $phone_mob;
$add_address['sheng'] = $sheng;
$add_address['shi'] = $shi;
$add_address['qu'] = $qu;
$user_address->data($add_address)->add();
}
} else {
$address = $user_address->where('uid=' . $this->visitor->info['id'])->find($address_options);
//取到地址
$data['address_name'] = $address['consignee'];
//收货人姓名
$data['mobile'] = $address['mobile'];
//电话号码
$data['address'] = $address['sheng'] . $address['shi'] . $address['qu'] . $address['address'];
//地址
}
if ($orderid = $item_order->data($data)->add()) {
//添加订单成功
$orders['orderId'] = $dingdanhao;
foreach ($_SESSION['cart'] as $item) {
$item_goods->where('id=' . $item['id'])->setDec('goods_stock', $item['num']);
$orders['itemId'] = $item['id'];
//商品ID
//.........这里部分代码省略.........
示例4: jiesuan
public function jiesuan()
{
//结算
$tokenTall = $this->getTokenTall();
$this->assign('tokenTall', $tokenTall);
if (count($_SESSION['cart']) > 0) {
$user_address_mod = M('user_address');
$address_list = $user_address_mod->where(array('uid' => $this->visitor->info['id']))->select();
$this->assign('address_list', $address_list);
//购物车按店铺分组
$result = $this->cart_by_group();
//按订单整合物流方式(合并各个商品的物流方式和金额)
foreach ($result as $key => $value) {
$free_style = 1;
$pingyou = 0;
$kuaidi = 0;
$ems = 0;
foreach ($value['item'] as $items) {
if ($items['free'] == '2') {
$free_style = 2;
$pingyou += floatval($items['pingyou']);
$kuaidi += floatval($items['kuaidi']);
$ems += floatval($items['ems']);
}
}
$result[$key]['free'] = $free_style;
$result[$key]['pingyou'] = $pingyou;
$result[$key]['kuaidi'] = $kuaidi;
$result[$key]['ems'] = $ems;
}
//header("content-Type: text/html; charset=Utf-8");
//dump($result);exit;
$this->assign('allinfo', $result);
import('Think.ORG.Cart');
// 导入购物车类
$cart = new Cart();
$sumPrice = $cart->getPrice();
$this->assign('sumPrice', $sumPrice);
$this->_config_seo();
$this->display();
} else {
$this->redirect('shopcart/index', array('tokenTall' => $tokenTall));
}
}
示例5: change_quantity
public function change_quantity()
{
import('Think.ORG.Cart');
// 导入购物车类
$cart = new Cart();
$itemId = $this->_post('itemId', 'intval');
//商品ID
$quantity = $this->_post('quantity', 'intval');
//购买数量
$spec_id = $this->_post('spec_id', 'intval');
//购买数量
$goods_stock = 0;
$spec_1 = '';
$spec_2 = '';
$price = 0;
$item = M('item')->field('id,title,img,price,goods_stock')->find($itemId);
if (!is_array($item)) {
$data = array('status' => 0, 'msg' => '不存在该商品', 'count' => $cart->getCnt(), 'sumPrice' => $cart->getPrice());
}
if ($spec_id == 0) {
$goods_stock = $item['goods_stock'];
$price = $item['price'];
} else {
$item_spec = M('item_spec')->field('spec_1,spec_2,price,stock')->find($spec_id);
$goods_stock = $item_spec['stock'];
$price = $item_spec['price'];
$spec_1 = $item_spec['spec_1'];
$spec_2 = $item_spec['spec_2'];
}
if ($goods_stock < $quantity) {
$data = array('status' => 0, 'msg' => '没有足够的库存', 'count' => $cart->getCnt(), 'sumPrice' => $cart->getPrice());
} else {
$cart->modNum($itemId, $spec_id, $quantity);
$data = array('status' => 1, 'item' => $cart->getItem($itemId, $spec_id), 'sumPrice' => $cart->getPrice());
}
echo json_encode($data);
}
示例6: pay
public function pay()
{
$this->is_login();
$userinfo = session('P');
$wxpay_config = $this->ag_hongbao_config();
if (empty($wxpay_config['Allow_type'])) {
$this->error('暂不支持任何形式付款');
}
if (IS_POST && count($_SESSION['cart']) > 0) {
import('@.ORG.Cart');
$cart = new \Cart();
$user_address = M('shop_useraddress');
$item_order = M('shop_orders');
$order_detail = M('order_detail');
//生成订单号
$dingdanhao = date("Y-m-dH-i-s");
$dingdanhao = str_replace("-", "", $dingdanhao);
$dingdanhao .= rand(1000, 9999);
$time = time();
//订单添加时间
$address_options = I('post.address_options', '', 'intval');
//地址 0:刚填的地址 大于0历史的地址
$shipping_id = I('post.shipping_id', '', 'intval');
//配送方式
$postscript = I('post.postscript', '', 'trim');
//卖家留言
if (!empty($postscript)) {
//卖家留言
$data['note'] = $postscript;
}
//仅支持卖家包邮
//if(empty($shipping_id)){//卖家包邮
$data['freetype'] = 0;
$data['order_sumPrice'] = $cart->getPrice();
//} else{
// $data['freetype'] = $shipping_id;
// $data['freeprice'] = $this->getFree($shipping_id);//取到运费
// $data['order_sumPrice'] = $cart->getPrice()+$this->getFree($shipping_id);
//}
$data['orderId'] = $dingdanhao;
//订单号
$data['add_time'] = $time;
//添加时间
$data['goods_sumPrice'] = $cart->getPrice();
//商品总额
$data['userId'] = $userinfo['id'];
//用户ID
if ($address_options == 0) {
$consignee = I('post.consignee', '', 'trim');
//真实姓名
$sheng = I('post.sheng', '', 'trim');
//省
$shi = I('post.shi', '', 'trim');
//市
$qu = I('post.qu', '', 'trim');
//区
$address = I('post.address', '', 'trim');
//详细地址
$phone_mob = I('post.phone_mob', '', 'trim');
//电话号码
$save_address = I('post.save_address', '', 'trim');
//是否保存地址
$data['address_name'] = $consignee;
//收货人姓名
$data['mobile'] = $phone_mob;
//电话号码
$data['address'] = $sheng . $shi . $qu . $address;
//地址
//自动保存地址进数据库
if ($save_address) {
$add_address['consignee'] = $consignee;
$add_address['address'] = $address;
$add_address['mobile'] = $phone_mob;
$add_address['sheng'] = $sheng;
$add_address['shi'] = $shi;
$add_address['qu'] = $qu;
$user_address->add($add_address);
}
} else {
$userId = $userinfo['id'];
//提取用户地址
$address = $user_address->where("uid='{$userId}'")->find($address_options);
//取到地址
$data['address_name'] = $address['consignee'];
//收货人姓名
$data['mobile'] = $address['mobile'];
//电话号码
$data['address'] = $address['sheng'] . $address['shi'] . $address['qu'] . $address['address'];
//地址
}
$orderid = $item_order->add($data);
//添加订单
if ($orderid) {
$orders['orderId'] = $dingdanhao;
$item_goods = M('docunment_shop');
foreach ($_SESSION['cart'] as $item) {
//减少库存
$item_goods->where(array('id' => $item['id']))->setDec('shop_goods_stock', $item['num']);
//$item_goods->where('id ='.$item['id'])->setDec('goods_stock',$item['num']);
$orders['itemId'] = $item['id'];
//.........这里部分代码省略.........
示例7: Cart
session_start();
require_once './function/DbConnect.php';
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
</head>
<body>
<?php
require_once './Cart.php';
$con = DbConnect::Connection();
$cart = new Cart(1);
echo "<table border=1>";
$data = $_SESSION['cart'];
echo "<tr><td>菜品名</td><td>单价</td><td>数量</td></tr>";
foreach ($data as $item) {
$queryFood = DbConnect::queryFoodById($con, $item['id']);
$resultFood = mysql_fetch_array($queryFood);
echo "<tr><td>" . $resultFood['name'] . "</td><td>" . $item['price'] . "</td><td>" . $item['num'] . "</td></tr>";
}
echo "</table>";
echo $cart->getPrice();
echo "<form action='submit.php' method='post'>";
echo "</br>请选择配送方式,选择‘配送’即为配送到宿舍,如果您想自己顺路带回宿舍,请选择‘自取’,在学三楼下曙光打印店附近餐车处领餐</br>";
echo "<select name='type'><option value=\"配送\">配送</option><option value=\"自取\">自取</option><option value=\"订餐送TA\">订餐送TA</option></select></br>";
echo "<input type='submit'>";
?>
</body>
</html>