本文整理汇总了PHP中Cart::clear方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart::clear方法的具体用法?PHP Cart::clear怎么用?PHP Cart::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart
的用法示例。
在下文中一共展示了Cart::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionLogout
public function actionLogout()
{
// Удаляем информацию о пользователе из сессии
unset($_SESSION['user']);
Cart::clear();
// Перенаправляем пользователя на главную страницу
header('Location:/');
}
示例2: getDone
public function getDone(Request $request)
{
$id = $request->get('paymentId');
$token = $request->get('token');
$payer_id = $request->get('PayerID');
$payment = PayPal::getById($id, $this->_apiContext);
$paymentExecution = PayPal::PaymentExecution();
$paymentExecution->setPayerId($payer_id);
$executePayment = $payment->execute($paymentExecution, $this->_apiContext);
\Cart::clear();
return view('frontend.checkout.done')->with('categories', Category::all())->with('pay', $executePayment);
}
示例3: actionCheckout
/**
* Action для страницы "Оформление покупки"
*/
public function actionCheckout()
{
// Получаем данные из корзины
$productsInCart = Cart::getProductsInCart();
// Если товаров нет, отправляем пользователи искать товары на главную
if ($productsInCart == false) {
header("Location: /");
}
// Список категорий для левого меню
$categories = Category::getCategoriesList();
// Находим общую стоимость
$productsIds = array_keys($productsInCart);
$products = Product::getProductsByIds($productsIds);
$totalPrice = Cart::getTotalPrice($products);
// Количество товаров
$totalQuantity = Cart::cartItems();
// Поля для формы
$userName = false;
$userPhone = false;
$userComment = false;
// Статус успешного оформления заказа
$result = false;
// Проверяем является ли пользователь гостем
if (!User::isGuest()) {
// Если пользователь не гость
// Получаем информацию о пользователе из БД
$userId = User::checkLogged();
$user = User::getUserById($userId);
$userName = $user['name'];
} else {
// Если гость, поля формы останутся пустыми
$userId = false;
}
// Обработка формы
if (isset($_POST['submit'])) {
// Если форма отправлена
// Получаем данные из формы
$userName = $_POST['userName'];
$userPhone = $_POST['userPhone'];
$userComment = $_POST['userComment'];
// Флаг ошибок
$errors = false;
// Валидация полей
if (!User::checkName($userName)) {
$errors[] = 'Неправильное имя';
}
if (!User::checkPhone($userPhone)) {
$errors[] = 'Неправильный телефон';
}
if ($errors == false) {
// Если ошибок нет
// Сохраняем заказ в базе данных
$result = Order::save($userName, $userPhone, $userComment, $userId, $productsInCart);
if ($result) {
// Если заказ успешно сохранен
// Оповещаем администратора о новом заказе по почте
$adminEmail = 'polytov11@mail.ru';
$message = 'Cписок заказов';
$subject = 'Новый заказ!';
mail($adminEmail, $subject, $message);
// Очищаем корзину
Cart::clear();
}
}
}
// Подключаем вид
require_once ROOT . '/views/cart/checkout.php';
return true;
}
示例4: actionSubmit
public function actionSubmit()
{
if (isset($_POST)) {
// Получаем данные из формы
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
// Валидация данных
$message = Cart::validation($name, $phone);
if ($message['name'] || $message['phone']) {
require_once ROOT . '/views/cart/submit_err.php';
} else {
// Если ошибок нет, сохраняем данные о пользователе в базе данных
$id = Cart::saveUser($name, $email, $phone);
// Формируем описание заказа в виде строк
$order = Cart::getServices();
if ($order) {
$servicesIds = array_keys($order);
$services = Services::getServicesDetailed($servicesIds);
$totalSum = Cart::getTotalSum($services);
$orderDetails = 'Новый заказ ';
$orderDetails .= 'от пользователя: id=' . $id . ', имя: ' . $name . ', email: ' . $email . ', тел.: ' . $phone . '. ';
foreach ($services as $service) {
$orderDetails .= $service["name"] . ' (id = ' . $service["id"] . ') по цене ' . $service["price"] . ' грн. в количестве ' . $order[$service["id"]] . '. ';
}
$orderDetails .= 'На общую сумму ' . $totalSum . ' грн.';
// Сохраняем заказ в базе данных
$orderId = Cart::saveOrder($id, $orderDetails);
}
// Если заказ сохранен
if ($orderId != 0) {
// Оповещаем администратора о новом заказе по почте
$adminEmail = 'ad.fl87@mail.ru';
$subject = 'Новый заказ! Номер ' . $orderId;
$message = 'От пользователя: id=' . $id . ', имя: ' . $name . ', email: ' . $email . ', тел.: ' . $phone . '.';
// Если письмо успешно отправлено
if (mail($adminEmail, $subject, $message)) {
// Очищаем корзину
Cart::clear();
}
}
require_once ROOT . '/views/cart/done.php';
}
} else {
require_once ROOT . '/views/cart/submit.php';
}
return true;
}
示例5: pay
//.........这里部分代码省略.........
$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'];
//商品ID
$orders['title'] = $item['name'];
//商品名称
$orders['img'] = $item['img'];
//商品图片
$orders['price'] = $item['price'];
//商品价格
$orders['quantity'] = $item['num'];
//购买数量
$order_detail->add($orders);
}
$cart->clear();
//清空购物车
$this->assign('orderid', $orderid);
//订单ID
$this->assign('dingdanhao', $dingdanhao);
//订单号
$this->assign('order_sumPrice', $data['order_sumPrice']);
} else {
$this->error('生成订单失败!');
}
} else {
if (isset($_GET['orderId'])) {
$item_order = M('shop_orders');
//订单号
$userId = $userinfo['id'];
//去除单号 安全后缀 空格
$orderId = str_replace(' ', '', str_replace('.html?showwxpaytitle=1', '', $_GET['orderId']));
$orders = $item_order->where("userId='{$userId}' and orderId='{$orderId}'")->find();
if (!is_array($orders)) {
$this->error('该订单不存在');
}
Wxpay::get_prepay_id();
if (empty($orders['supportmetho'])) {
//是否已有支付方式
$this->assign('orderid', $orders['id']);
//订单ID
$this->assign('dingdanhao', $orders['orderId']);
//订单号
$this->assign('order_sumPrice', $orders['order_sumPrice']);
} else {
//微信支付
$alipay = M('alipay')->find();
echo "<script>location.href='wapapli/alipayapi.php?WIDseller_email=" . $alipay['alipayname'] . "&WIDout_trade_no=" . $orderId . "&WIDsubject=" . $orderId . "&WIDtotal_fee=" . $orders['order_sumPrice'] . "'</script>";
die;
}
}
}
$this->book_menu($userinfo);
//选择支付方式 货到付款 微信支付
if (!empty($wxpay_config['hb_dh_diyong'])) {
$time = time();
$map['hb_star'] = array('lt', $time);
$map['hb_end'] = array('gt', $time);
$map['status'] = 1;
$map['userid'] = $userinfo['id'];
$hblist = M('wxpay_userhongbao')->where($map)->select();
$this->assign('hblist', $hblist);
}
$this->assign('paylist', $wxpay_config['Allow_type']);
$this->display();
}
示例6: get_clear
function get_clear($id = null)
{
$ids = (array) $this->in('id', null);
$id and $ids[] = $id;
if ($ids) {
foreach ($ids as $id) {
Cart::clear($id);
}
} else {
Cart::clear();
}
$this->status($ids ? 'remove' : 'clear', array('title' => ''));
return $this->back(Cart::has() ? route('vanemart::cart') : '/');
}
示例7: pay
//.........这里部分代码省略.........
$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']);
$orders['itemId'] = $item['id'];
//商品ID
$orders['title'] = $item['name'];
//商品名称
$orders['img'] = $item['img'];
//商品图片
$orders['price'] = $item['price'];
//商品价格
$orders['quantity'] = $item['num'];
//购买数量
$orders['color'] = $item['color'];
//购买数量
$order_detail->data($orders)->add();
}
$cart->clear();
//清空购物车
$payment_id = $_POST['payment_id'];
$item_order = M('item_order')->where(" orderId='{$dingdanhao}'")->find();
!$item_order && $this->_404();
$title = '新订单' . $data['goods_sumPrice'] . '元';
$content = '您收到订单' . $dingdanhao . ',商品' . $orders['quantity'] . '件,总价格' . $data['goods_sumPrice'] . '元。购买者姓名:' . $consignee . '。收货人地址:' . $data['address'];
$tips_data = M('setting')->where(" name='tips'")->find();
$emails = unserialize($tips_data['data']);
if ($payment_id == 2) {
$data['status'] = 2;
$data['supportmetho'] = 2;
$data['support_time'] = time();
if (M('item_order')->where("orderId='{$dingdanhao}'")->data($data)->save()) {
$_SESSION['end'] = 1;
if ($emails && !empty($emails)) {
$mailer = mailer::get_instance();
$mailer->send($emails, $title, $content);
}
$this->redirect('Shopcart/index');
} else {
$this->error('操作失败!');
}
} elseif ($payment_id == 1) {
$data['supportmetho'] = 1;
$userId = $this->visitor->info['id'];
if (M('item_order')->where("and orderId='{$dingdanhao}'")->data($data)->save()) {
$alipay = M('alipay')->find();
echo "<script>location.href='api/wapalipay/alipayapi.php?WIDseller_email=" . $alipay['alipayname'] . "&WIDout_trade_no=" . $dingdanhao . "&WIDsubject=" . $dingdanhao . "&WIDtotal_fee=" . $item_order['order_sumPrice'] . "'</script>";
} else {
$this->error('操作失败!');
}
} else {
示例8: pay
//.........这里部分代码省略.........
$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
$orders['title'] = $item['name'];
//商品名称
$orders['img'] = $item['img'];
//商品图片
$orders['price'] = $item['price'];
//商品价格
$orders['quantity'] = $item['num'];
//购买数量
$order_detail->data($orders)->add();
}
$cart->clear();
//清空购物车
$this->assign('orderid', $orderid);
//订单ID
$this->assign('dingdanhao', $dingdanhao);
//订单号
$this->assign('order_sumPrice', $data['order_sumPrice']);
} else {
$this->error('生成订单失败!');
}
} elseif (isset($_GET['orderId'])) {
$item_order = M('item_order');
$orderId = $_GET['orderId'];
//订单号
$orders = $item_order->where('userId=' . $this->visitor->info['id'] . ' and orderId=' . $orderId)->find();
if (!is_array($orders)) {
$this->_404();
}
if (empty($orders['supportmetho'])) {
//是否已有支付方式
$this->assign('orderid', $orders['id']);
//订单ID
$this->assign('dingdanhao', $orders['orderId']);
//订单号
$this->assign('order_sumPrice', $orders['order_sumPrice']);
} else {
$alipay = M('alipay')->find();
echo "<script>location.href='wapapli/alipayapi.php?WIDseller_email=" . $alipay['alipayname'] . "&WIDout_trade_no=" . $orderId . "&WIDsubject=" . $orderId . "&WIDtotal_fee=" . $orders['order_sumPrice'] . "'</script>";
exit;
}
} else {
$this->redirect('user/index');
}
$this->display();
}
示例9: pay
//.........这里部分代码省略.........
//地址
$data['freetype'] = $freetype;
//配送方式
$data['freeprice'] = $free_sum;
//配送金额
$data['tokenTall'] = $key;
$all_order_arr[] = $dingdanhao;
$all_order_price = $all_order_price + $goods_sum + $free_sum;
if ($orderid = $item_order->data($data)->add()) {
$orders = array();
$orders['orderId'] = $dingdanhao;
foreach ($value['item'] as $item) {
$item_goods->where('id=' . $item['id'])->setDec('goods_stock', $item['num']);
$orders['itemId'] = $item['id'];
//商品ID
$orders['title'] = $item['name'];
//商品名称
$orders['img'] = $item['img'];
//商品图片
$orders['price'] = $item['price'];
//商品价格
$orders['quantity'] = $item['num'];
//购买数量
$orders['size'] = $item['size'];
//购买大小
$orders['color'] = $item['color'];
//购买颜色
$order_detail->data($orders)->add();
//添加订单明细
}
} else {
$this->error('生成订单失败!');
}
}
$cart->clear();
//清空购物车
//$this->assign('orderid',$orderid);//订单ID
//$this->assign('dingdanhao',$dingdanhao);//订单号
//$this->assign('order_sumPrice',$data['order_sumPrice']);
//header("content-Type: text/html; charset=Utf-8");
//dump(implode(',', $all_order_arr));exit;
//重新生成一个合并订单号,用于支付,并将原订单号和合并订单号的关联关系写入表中。
$merge = date("Y-m-dH-i-s");
$merge = str_replace("-", "", $merge);
$merge .= rand(1000, 2000);
foreach ($all_order_arr as $order) {
$data1['orderid'] = $order;
$data1['mergeid'] = $merge;
M('order_merge')->where("orderid='" . $order . "'")->delete();
M('order_merge')->data($data1)->add();
}
//$this->assign('dingdanhao', implode(',', $all_order_arr));//所有订单
//所有订单号
$this->assign('allorderid', $all_order_arr);
//支付号
$this->assign('dingdanhao', $merge);
$this->assign('order_sumPrice', $all_order_price);
//总金额
$this->assign('order_zhifu', '0');
} else {
if (isset($_GET['orderId'])) {
$item_order = M('item_order');
$orderId = $_GET['orderId'];
//订单号
$orders = $item_order->where("userId='" . $this->visitor->info['id'] . "' and orderId='" . $orderId . "'")->find();
if (!is_array($orders)) {
$this->_404();
}
$this->assign('orderid', $orders['id']);
//订单ID
/*
* 不能这么干,应该发起查询,如果没有支付,则再进行支付。by zcb
//重新生成一个合并订单号,用于支付,并将原订单号和合并订单号的关联关系写入表中。
$merge = date("Y-m-dH-i-s");
$merge = str_replace("-","",$merge);
$merge .= rand(1000,2000);
M('order_merge')->where("orderid='".$orderId."'")->delete();
M('order_merge')->data(array('orderid'=>$orderId, 'mergeid'=>$merge))->add();
*/
$merge = M('order_merge')->where(array('orderid' => $orderId))->find();
//支付号
$this->assign('dingdanhao', $merge['mergeid']);
//订单号
$this->assign('allorderid', array($orderId));
$this->assign('order_sumPrice', $orders['order_sumPrice']);
$this->assign('order_exist', '1');
if (empty($orders['supportmetho'])) {
$this->assign('order_zhifu', '0');
} else {
//$alipay=M('alipay')->find();
//echo "<script>location.href='wapapli/alipayapi.php?WIDseller_email=".$alipay['alipayname']."&WIDout_trade_no=".$orderId."&WIDsubject=".$orderId."&WIDtotal_fee=".$orders['order_sumPrice']."'</script>";
//exit;
$this->assign('order_zhifu', $orders['supportmetho']);
}
} else {
$this->redirect('user/index', array('tokenTall' => $tokenTall));
}
}
$this->display();
}
示例10: action_clear_cart
public function action_clear_cart()
{
$items = \Cart::items();
$order = null;
if (is_numeric(\Session::get('order.id'))) {
$order = \Order\Model_Order::find_one_by_id(\Session::get('order.id'));
}
if ($order) {
$order->delete();
}
if ($items) {
foreach ($items as $item) {
// Find artworks
if ($unique_id = $item->get('unique_id')) {
if ($artworks = \Order\Model_Artwork::find(array('where' => array('unique_id' => $unique_id, 'order_id' => \Session::get('order.id'))))) {
$ysi = \Yousendit\Base::forge();
// Artworks (update, delete)
foreach ($artworks as $artwork) {
// Remove deleted artwork
if ($artwork->file_id) {
$ysi->delete_artwork($artwork->file_id);
}
}
}
}
}
}
// Delete order & cart session
\Session::delete('order.id');
\Cart::clear();
\Messages::info('Your cart is empty.');
if (\Input::is_ajax()) {
echo \Messages::display();
exit;
} else {
\Response::redirect(\Input::referrer(\Uri::create('order/checkout/address')));
}
}
示例11: loadApi
function loadApi($action)
{
switch ($action) {
case 'htmlpopupdata':
$htmlData = Cart::htmlPopupData();
$data = json_encode(array('data' => $htmlData));
return $data;
break;
case 'add_product':
if (!Request::has(array('productid', 'quantity'))) {
throw new Exception("Product not valid.");
}
try {
Cart::addProduct(Request::get('productid'), Request::get('quantity'));
$data = json_encode(array('error' => 'no', 'message' => 'Add product success.'));
return $data;
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
break;
case 'remove_product':
if (!Request::has('productid')) {
throw new Exception("Product not valid.");
}
Cart::removeProduct(Request::get('productid'));
$data = json_encode(array('error' => 'no', 'message' => 'Remove product success.'));
return $data;
break;
case 'remove_coupon':
if (!Request::has('code')) {
throw new Exception("Coupon not valid.");
}
Cart::removeCoupon();
$data = json_encode(array('error' => 'no', 'message' => 'Remove coupon success.'));
return $data;
break;
case 'remove_voucher':
if (!Request::has('code')) {
throw new Exception("Voucher not valid.");
}
Cart::removeVoucher();
$data = json_encode(array('error' => 'no', 'message' => 'Remove voucher success.'));
return $data;
break;
case 'clear':
Cart::clear();
$data = json_encode(array('error' => 'no', 'message' => 'Clear cart success.'));
return $data;
break;
case 'add_coupon':
if (!Request::has('code')) {
throw new Exception("Coupon code not valid.");
}
try {
Cart::addCoupon(Request::get('code'));
$data = json_encode(array('error' => 'no', 'message' => 'Add coupon success.'));
return $data;
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
break;
case 'add_voucher':
if (!Request::has('code')) {
throw new Exception("Voucher code not valid.");
}
try {
Cart::addVoucher(Request::get('code'));
$data = json_encode(array('error' => 'no', 'message' => 'Add voucher success.'));
return $data;
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
break;
}
}
示例12: actionCheckout
public function actionCheckout()
{
// get data from Cart
$productInCart = Cart::getProduct();
if ($productInCart == false) {
header("Location: /");
}
// get categories list for left menu
$categories = Category::getCategoriesList();
// get total price
$productsId = array_keys($productInCart);
$products = Product::getProductByIds($productsId);
$totalPrice = Cart::getTotalPrice($products);
// get count of products
$totalQuantity = Cart::countItems();
// fields for form
$userName = false;
$userPhone = false;
$userComment = false;
// the status of a successful checkout
$result = false;
// check is user guest
if (!User::isGuest()) {
// if user not guest get his info from database
$userId = User::checkLogged();
$user = User::getUserById($userId);
$userName = $user['name'];
} else {
// if user is guest -- the forms field will be empty
$userId = false;
}
if (isset($_POST['submit'])) {
// read form data
$userName = $_POST['userName'];
$userPhone = $_POST['userPhone'];
$userComment = $_POST['userComment'];
// data validation
$errors = false;
if (!User::checkName($userName)) {
$errors[] = 'Wrong input name';
}
if (!User::checkPhoneNumber($userPhone)) {
$errors[] = 'Wrong intup Phone number';
}
if ($errors == false) {
// data input correctly
// save order in database
$result = Order::save($userName, $userPhone, $userComment, $userId, $productInCart);
// send email
if ($result) {
// $adminEmail = 'jlumarlin@gmail.com';
// $message = 'future link on admin part';
// $subject = 'New order';
// mail($adminEmail, $subject, $message);
// clear the cart
Cart::clear();
}
}
}
require_once ROOT . '/views/cart/checkout.php';
return true;
}
示例13: Cart
require_once ROOT . DS . 'controllers' . DS . 'cart.class.php';
require_once ROOT . DS . 'controllers' . DS . 'cookie.class.php';
require_once 'db.class.php';
$cart = new Cart();
$db = new DB($db_host, $db_user, $db_password, $db_name);
$action = isset($_GET['action']) ? $_GET['action'] : 'list';
if ($action == 'add') {
$id = $_GET['id'];
$cart->addProduct($id);
header('Location: index.php');
} elseif ($action == 'delete') {
$id = $_GET['id'];
$cart->deleteProduct($id);
header('Location: cart.php');
} elseif ($action == 'clear') {
$cart->clear();
header('Location: cart.php');
} else {
if ($cart->isEmpty()) {
echo "Cart is empty";
} else {
$id_sql = $cart->getProducts(true);
$sql = "SELECT * FROM books WHERE id IN ({$id_sql})";
$books = $db->query($sql);
echo "My cart: <br>";
foreach ($books as $book) {
echo "<b>{$book['title']}</b> <a href='cart.php?action=delete&id={$book['id']}'>Delete from cart</a> <br>";
}
}
}
?>
示例14: actionClear
public function actionClear()
{
Cart::clear();
}
示例15: intval
//.........这里部分代码省略.........
$is_success = $regimentRelationObj->update('id = ' . $resultData['relation_id']);
}
if ($is_success == '' || $resultData['flag'] == false) {
$errorMsg = isset($resultData['data']) && $resultData['data'] != '' ? $resultData['data'] : '团购报名失败';
IError::show(403, $errorMsg);
exit;
}
} else {
if ($promo == 'time') {
$order_type = 2;
}
}
}
//付款方式,判断是否为货到付款
$deliveryObj = new IModel('delivery');
$deliveryRow = $deliveryObj->getObj('id = ' . $delivery_id, 'type');
if ($deliveryRow['type'] == 0 && $payment == 0) {
IError::show(403, '请选择支付方式');
} else {
if ($deliveryRow['type'] == 1) {
$payment = 0;
}
}
$countSumObj = new CountSum();
//直接购买商品方式
if ($type != '' && $gid != 0) {
//计算$gid商品
$goodsResult = $countSumObj->direct_count($gid, $type, $num, $promo, $active_id);
} else {
//计算购物车中的商品价格$goodsResult
$goodsResult = $countSumObj->cart_count();
//清空购物车
$cartObj = new Cart();
$cartObj->clear();
}
//判断商品商品是否存在
if (empty($goodsResult['goodsList']) && empty($goodsResult['productList'])) {
IError::show(403, '商品数据不存在');
exit;
}
$sum_r = $goodsResult['sum'];
$proReduce_r = $goodsResult['proReduce'];
$reduce_r = $goodsResult['reduce'];
$final_sum_r = $goodsResult['final_sum'];
$freeFreight_r = $goodsResult['freeFreight'];
$point_r = $goodsResult['point'];
$exp_r = $goodsResult['exp'];
//计算运费$deliveryPrice和保价$protect_price
$deliveryList = Delivery::getDelivery($province, $goodsResult['weight'], $final_sum_r);
$deliveryPrice = $deliveryList[$delivery_id]['price'];
if ($is_protectPrice == null) {
$protect_price = 0;
$if_insured = 0;
} else {
$protect_price = $deliveryList[$delivery_id]['protect_price'];
$if_insured = 1;
}
if ($freeFreight_r == true) {
$deliveryPrice_r = 0;
} else {
$deliveryPrice_r = $deliveryPrice;
}
//获取红包减免金额
if ($ticket_id != '') {
$memberObj = new IModel('member');
$memberRow = $memberObj->getObj('user_id = ' . $user_id, 'prop,custom');