本文整理汇总了PHP中Cart::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart::update方法的具体用法?PHP Cart::update怎么用?PHP Cart::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart
的用法示例。
在下文中一共展示了Cart::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
public function delete()
{
if (parent::delete()) {
$cart = new Cart($this->id_cart);
$cart->status = Cart::IS_CLOSE;
return $cart->update();
}
return false;
}
示例2: postDelete
public function postDelete()
{
if (Request::ajax()) {
$productId = Input::get('productId');
$rows = Cart::search(array('id' => $productId));
$rowId = $rows[0];
Cart::update($rowId, 0);
$total = Cart::total();
return Response::json(array('productId' => $productId, 'quantity' => $quantity, 'total' => $total));
}
}
示例3: update
/**
* 更新购物车
*/
public function update()
{
//不是ajax提交返回
$sid = $_POST['sid'];
if (!IS_AJAX) {
return;
}
//购物车更新
Cart::update($_POST);
//获得所有商品数据
$total = Cart::getAllData();
$total['xiaoji'] = $total['goods'][$sid]['total'];
$this->ajax($total);
}
示例4: displayMain
public function displayMain()
{
global $smarty, $cookie, $link;
$cart = new Cart((int) $cookie->id_cart);
if (isset($_POST['msg']) && pSQL($_POST['msg'], true) != $cart->msg) {
$cart->msg = substr(pSQL($_POST['msg'], true), 0, 500);
$cart->update();
}
if (!$cookie->logged || !User::checkPassword($cookie->id_user, $cookie->passwd)) {
Tools::redirect($link->getPage('LoginView', false, array('step' => 2)));
} else {
$this->LoginedAction();
}
$smarty->assign(array('id_default_carrier' => Configuration::get('TM_DEFAULT_CARRIER_ID')));
return $smarty->fetch('checkout.tpl');
}
示例5: displayMain
public function displayMain()
{
global $cookie, $link;
if (!isset($cookie->id_cart) || !$cookie->logged) {
Tools::redirect($link->getPage('UserView'));
}
if (!Tools::getRequest('id_module') || !Tools::getRequest('id_address')) {
Tools::redirect($link->getPage('CheckoutView'));
}
$cart = new Cart((int) $cookie->id_cart);
$cart->id_address = (int) Tools::getRequest('id_address');
$cart->id_carrier = (int) Tools::getRequest('id_carrier');
$cart->update();
$payment = Module::hook((int) Tools::getRequest('id_module'));
if (!$payment->active) {
Tools::redirect($link->getPage('CheckoutView'));
}
return $payment->execPayment($cart);
}
示例6: logined
public function logined($vals = array())
{
global $cookie;
$cookie->logged = 1;
$cookie->id_user = $this->id;
$cookie->email = $this->email;
$cookie->passwd = $this->passwd;
$cookie->first_name = $this->first_name;
$cookie->last_name = $this->last_name;
if (count($vals) > 0) {
foreach ($vals as $key => $val) {
$cookie->{$key} = $val;
}
}
if (isset($cookie->id_cart)) {
$cart = new Cart((int) $cookie->id_cart);
$cart->id_user = $this->id;
if (isset($vals['id_address'])) {
$cart->id_address = (int) $vals['id_address'];
}
$cart->update();
}
$cookie->write();
}
示例7: add
function add($item_id, $item_table, $qty = false, $table = false)
{
global $CFG;
$table = $table ? $table : 'cart';
$item = DB::getRecord($item_table, $item_id, false, true);
$item_name = $item['name'];
if (!($item_id > 0) && !$item) {
$errors[$item_id] = $CFG->cart_item_error;
Errors::merge($errors);
return false;
}
if (empty($item_table)) {
$errors[$item_id] = $CFG->cart_table_error;
Errors::merge($errors);
return false;
}
if (!($qty > 0)) {
$errors[$item_id] = $CFG->cart_qty_error;
Errors::merge($errors);
return false;
}
if ($c_item = Cart::getItem($item_id, $item_table, $table)) {
return Cart::update($item_id, $item_table, $c_item['qty'] + $qty, $table);
}
if (User::isLoggedIn()) {
$id = DB::insert($table, array('item_id' => $item_id, 'item_table' => $item_table, 'qty' => $qty, 'user_id' => User::$info['id']));
$messages[$item_name] = str_ireplace('[qty]', $qty, $CFG->cart_add_message);
Messages::merge($messages);
return $id;
} else {
$_SESSION['cart'][$item_table . '_' . $item_id] = array('item_id' => $item_id, 'item_table' => $item_table, 'qty' => $qty);
$messages[$item_name] = str_ireplace('[qty]', $qty, $CFG->cart_add_message);
Messages::merge($messages);
return true;
}
}
示例8: 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');
}
示例9: saveItemGaji
public function saveItemGaji($id)
{
// 1. setting validasi
$messages = array('required' => 'Inputan <b>Tidak Boleh Kosong</b>!', 'numeric' => 'Inputan <b>Harus Angka</b>!', 'same' => 'Password <b>Tidak Sama</b>!');
$validator = Validator::make(Input::all(), array("nilgj" => "required"), $messages);
// 2a. jika semua validasi terpenuhi simpan ke database
if ($validator->passes()) {
// Cart::add(1, 5, 5, 5);
$content = Cart::content();
$idcart = 1;
$rowId = '';
foreach ($content as $row) {
if ($row->name == Input::get("idgj")) {
$idcart = $row->id;
$rowId = $row->rowid;
break;
} else {
$idcart = $row->id;
$idcart += 1;
}
}
if ($rowId != '') {
Cart::update($rowId, array('price' => Input::get("nilgj")));
} else {
if (Input::get("idgj")) {
$idgj = Input::get("idgj");
$gaji = mg01::find($idgj);
$jenis = $gaji['jenis'];
Cart::add($idcart, Input::get("idgj"), 1, Input::get("nilgj"), array('jenis_gaji' => $jenis, "idkaryawan" => Input::get("idkaryawan"), "iduser" => 0));
}
}
// Redirect ke url + menuju div tertentu
$url = URL::action("MasterKaryawanController@addGaji", ['id' => $id]) . "#datatable";
return Redirect::to($url);
} else {
return Redirect::to('master/karyawan/add_gaji/' . $id)->withErrors($validator)->withInput();
}
}
示例10: postCart
public function postCart()
{
if (Request::ajax()) {
if (isset($_POST['buypid'])) {
$optionprice = $name = DB::table('products_options')->where('product_id', $_POST['buypid'])->where("option_value", $_POST['buyoption'])->pluck('price');
return $optionprice;
exit;
}
if (isset($_POST['pid'])) {
$item = Product::find($_POST['pid']);
Cart::update($_POST['rowid'], array('qty' => $_POST['qty']));
$content = Cart::content();
$total = Cart::total();
$itemHtml = "";
/*$itemHtml .="<div class='beta-select'><i class='fa fa-shopping-cart'></i><span id='cart-count'> Cart (".Cart::count().")</span> <i class='fa fa-chevron-down'></i></div>
<div class='beta-dropdown cart-body'>";*/
if ($content) {
foreach ($content as $itemRow) {
$product = Product::find($itemRow->id);
if ($itemRow->options->has('buying') && $itemRow->options->buying != "") {
$itemRow->price = DB::table('products_options')->where("product_option_value_id", $itemRow->optionid)->pluck('price');
}
if (public_path()) {
$source_folder = public_path() . '/uploads/images/';
$destination_folder = public_path() . '/uploads/images/';
} else {
$source_folder = '/home/medicalng/public_html/uploads/images/';
$destination_folder = '/home/medicalng/public_html/uploads/images/';
}
$image_info = pathinfo($source_folder . $product->image);
$image_extension = strtolower($image_info["extension"]);
//image extension
$image_name_only = strtolower($image_info["filename"]);
//file name only, no extension
$imgName = $image_name_only . "-50x50" . "." . $image_extension;
$itemHtml .= "<div class='cart-item'>\n <!--<a class='cart-item-edit' pid='" . $itemRow->rowid . "' href=\"javascript:void(0);\"><i class='fa fa-pencil'></i></a>-->\n <a class='cart-item-delete' pid='" . $itemRow->rowid . "' href=\"javascript:void(0);\"><i class='fa fa-times'></i></a>\n <div class='media'>\n <a class='pull-left' href=\"javascript:void(0);\"><img src='" . url() . "/uploads/images/thumbs/{$imgName}' alt=''></a>\n <div class='media-body'>\n <span class='cart-item-title'>" . $itemRow->name . "</span>\n ";
$itemHtml .= "<span class='cart-item-options'>";
if ($itemRow->options) {
foreach ($itemRow->options as $key => $value) {
if ($value != "") {
$itemHtml .= $value . "&mdash";
}
}
}
$itemHtml .= "</span>";
$itemHtml .= "\n <span class='cart-item-amount'>{$itemRow->qty}*<span>₦" . number_format($itemRow->price, 2, '.', ',') . "</span>\n </div>\n </div>\n </div>\n\n ";
}
$itemHtml .= "<div class='cart-caption'>\n <div class='cart-total text-right'>Subtotal: <span class='cart-total-value'>₦" . number_format($total, 2, ".", ",") . "</span></div>\n <div class='clearfix'></div>\n\n <div class='center'>\n <div class='space10'> </div>\n <a href='" . url() . "/cart' class='beta-btn primary text-center'>Checkout <i class='fa fa-chevron-right'></i></a>\n </div></div>";
} else {
$itemHtml .= "Cart is empty";
}
/*$itemHtml .= "</div>";*/
echo $itemHtml;
}
if (isset($_POST['delid'])) {
//$item = Product::find($_POST['delid']);
Cart::remove($_POST['rowid']);
//(array('id' => $item->id, 'name' => $item->title, 'qty' => 1, 'price' => $item->price));
$content = Cart::content();
Session::put("cartItems", $content);
$total = Cart::total();
$itemHtml = "";
/*$itemHtml .="<div class='beta-select'><i class='fa fa-shopping-cart'></i><span id='cart-count'> Cart (".Cart::count().")</span> <i class='fa fa-chevron-down'></i></div>
<div class='beta-dropdown cart-body'>";*/
if ($content) {
foreach ($content as $itemRow) {
$product = Product::find($itemRow->id);
if ($itemRow->options->has('buying') && $itemRow->options->buying != "") {
$itemRow->price = DB::table('products_options')->where("product_option_value_id", $itemRow->optionid)->pluck('price');
}
if (public_path()) {
$source_folder = public_path() . '/uploads/images/';
$destination_folder = public_path() . '/uploads/images/';
} else {
$source_folder = '/home/medicalng/public_html/uploads/images/';
$destination_folder = '/home/medicalng/public_html/uploads/images/';
}
$image_info = pathinfo($source_folder . $product->image);
$image_extension = strtolower($image_info["extension"]);
//image extension
$image_name_only = strtolower($image_info["filename"]);
//file name only, no extension
$imgName = $image_name_only . "-50x50" . "." . $image_extension;
$itemHtml .= "<div class='cart-item'>\n <!--<a class='cart-item-edit' pid='" . $itemRow->rowid . "' href=\"javascript:void(0);\"><i class='fa fa-pencil'></i></a>-->\n <a class='cart-item-delete' pid='" . $itemRow->rowid . "' href=\"javascript:void(0);\"><i class='fa fa-times'></i></a>\n <div class='media'>\n <a class='pull-left' href=\"javascript:void(0);\"><img src='" . url() . "/uploads/images/thumbs/{$imgName}' alt=''></a>\n <div class='media-body'>\n <span class='cart-item-title'>" . $itemRow->name . "</span>\n ";
$itemHtml .= "<span class='cart-item-options'>";
$thml = "";
if ($itemRow->options) {
foreach ($itemRow->options as $key => $value) {
if ($value != "") {
$thml .= " —" . $value;
}
}
$thml = preg_replace("/^ —/", "", $thml);
}
$itemHtml .= $thml . "</span>";
$itemHtml .= "\n <span class='cart-item-amount'>{$itemRow->qty}*<span>₦" . number_format($itemRow->price, 2, '.', ',') . "</span>\n </div>\n </div>\n </div>\n\n ";
}
$itemHtml .= "<div class='cart-caption'>\n <div class='cart-total text-right'>Subtotal: <span class='cart-total-value'>₦" . number_format($total, 2, ".", ",") . "</span></div>\n <div class='clearfix'></div>\n\n <div class='center'>\n <div class='space10'> </div>\n <a href='" . url() . "/cart' class='beta-btn primary text-center'>Checkout <i class='fa fa-chevron-right'></i></a>\n </div></div>";
} else {
$itemHtml .= "Cart is empty";
//.........这里部分代码省略.........
示例11: _deleteProduct
private function _deleteProduct($orderDetail, $quantity)
{
$price = $orderDetail->product_price * (1 + $orderDetail->tax_rate * 0.01);
if ($orderDetail->reduction_percent != 0.0) {
$reduction_amount = $price * $orderDetail->reduction_percent / 100;
} elseif ($orderDetail->reduction_amount != '0.000000') {
$reduction_amount = Tools::ps_round($orderDetail->reduction_amount * (1 + $orderDetail->tax_rate * 0.01), 2);
}
if (isset($reduction_amount) and $reduction_amount) {
$price = Tools::ps_round($price - $reduction_amount, 2);
}
$unitPrice = number_format($price, 2, '.', '');
$productPrice = number_format($quantity * $price, 2, '.', '');
$productPriceWithoutTax = number_format($productPrice / (1 + $orderDetail->tax_rate * 0.01), 2, '.', '');
/* Update cart */
$cart = new Cart($this->id_cart);
$cart->updateQty($quantity, $orderDetail->product_id, $orderDetail->product_attribute_id, false, 'down');
// customization are deleted in deleteCustomization
$cart->update();
/* Update order */
$shippingDiff = $this->total_shipping - $cart->getOrderShippingCost();
$this->total_products -= $productPriceWithoutTax;
$this->total_products_wt -= $productPrice;
$this->total_shipping = $cart->getOrderShippingCost();
/* It's temporary fix for 1.3 version... waiting historization system on 1.4 version */
if ($orderDetail->product_quantity_discount != '0.000000') {
$this->total_paid -= $productPrice + $shippingDiff;
} else {
$this->total_paid = $cart->getOrderTotal();
}
$this->total_paid_real -= $productPrice + $shippingDiff;
/* Prevent from floating precision issues (total_products has only 2 decimals) */
if ($this->total_products < 0) {
$this->total_products = 0;
}
/* Prevent from floating precision issues */
$this->total_paid = number_format($this->total_paid, 2, '.', '');
$this->total_paid_real = number_format($this->total_paid_real, 2, '.', '');
$this->total_products = number_format($this->total_products, 2, '.', '');
$this->total_products_wt = number_format($this->total_products_wt, 2, '.', '');
/* Update order detail */
$orderDetail->product_quantity -= intval($quantity);
if (!$orderDetail->product_quantity) {
if (!$orderDetail->delete()) {
return false;
}
if (count($this->getProductsDetail()) == 0) {
global $cookie;
$history = new OrderHistory();
$history->id_order = intval($this->id);
$history->changeIdOrderState(_PS_OS_CANCELED_, intval($this->id));
if (!$history->addWithemail()) {
return false;
}
}
return $this->update();
}
return $orderDetail->update() and $this->update();
}
示例12: _deleteProduct
protected function _deleteProduct($orderDetail, $quantity)
{
$price = $orderDetail->product_price * (1 + $orderDetail->tax_rate * 0.01);
if ($orderDetail->reduction_percent != 0.0) {
$reduction_amount = $price * $orderDetail->reduction_percent / 100;
} elseif ($orderDetail->reduction_amount != '0.000000') {
$reduction_amount = Tools::ps_round($orderDetail->reduction_amount, 2);
}
if (isset($reduction_amount) && $reduction_amount) {
$price = Tools::ps_round($price - $reduction_amount, 2);
}
$productPriceWithoutTax = number_format($price / (1 + $orderDetail->tax_rate * 0.01), 2, '.', '');
$price += Tools::ps_round($orderDetail->ecotax * (1 + $orderDetail->ecotax_tax_rate / 100), 2);
$productPrice = number_format($quantity * $price, 2, '.', '');
/* Update cart */
$cart = new Cart($this->id_cart);
$cart->updateQty($quantity, $orderDetail->product_id, $orderDetail->product_attribute_id, false, 'down');
// customization are deleted in deleteCustomization
$cart->update();
/* Update order */
$shippingDiff = $this->total_shipping - $cart->getOrderShippingCost();
$this->total_products -= $productPriceWithoutTax;
// After upgrading from old version
// total_products_wt is null
// removing a product made order total negative
// and don't recalculating totals (on getTotalProductsWithTaxes)
if ($this->total_products_wt != 0) {
$this->total_products_wt -= $productPrice;
}
$this->total_shipping = $cart->getOrderShippingCost();
/* It's temporary fix for 1.3 version... */
if ($orderDetail->product_quantity_discount != '0.000000') {
$this->total_paid -= $productPrice + $shippingDiff;
} else {
$this->total_paid = $cart->getOrderTotal();
}
$this->total_paid_real -= $productPrice + $shippingDiff;
/* Prevent from floating precision issues (total_products has only 2 decimals) */
if ($this->total_products < 0) {
$this->total_products = 0;
}
if ($this->total_paid < 0) {
$this->total_paid = 0;
}
if ($this->total_paid_real < 0) {
$this->total_paid_real = 0;
}
/* Prevent from floating precision issues */
$this->total_paid = number_format($this->total_paid, 2, '.', '');
$this->total_paid_real = number_format($this->total_paid_real, 2, '.', '');
$this->total_products = number_format($this->total_products, 2, '.', '');
$this->total_products_wt = number_format($this->total_products_wt, 2, '.', '');
/* Update order detail */
$orderDetail->product_quantity -= (int) $quantity;
if (!$orderDetail->product_quantity) {
if (!$orderDetail->delete()) {
return false;
}
if (count($this->getProductsDetail()) == 0) {
$history = new OrderHistory();
$history->id_order = (int) $this->id;
$history->changeIdOrderState(Configuration::get('PS_OS_CANCELED'), (int) $this->id);
if (!$history->addWithemail()) {
return false;
}
}
return $this->update();
}
return $orderDetail->update() && $this->update();
}
示例13: Paypal
$paypal = new Paypal();
$cart = new Cart((int) $cookie->id_cart);
$address = new Address((int) $cart->id_address_delivery);
$country = new Country((int) $address->id_country);
$state = NULL;
if ($address->id_state) {
$state = new State((int) $address->id_state);
}
$customer = new Customer((int) $cart->id_customer);
$business = Configuration::get('PAYPAL_BUSINESS');
$header = Configuration::get('PAYPAL_HEADER');
$currency_order = new Currency((int) $cart->id_currency);
$currency_module = $paypal->getCurrency((int) $cart->id_currency);
if (empty($business) or !Validate::isEmail($business)) {
die($paypal->getL('Paypal error: (invalid or undefined business account email)'));
}
if (!Validate::isLoadedObject($address) or !Validate::isLoadedObject($customer) or !Validate::isLoadedObject($currency_module)) {
die($paypal->getL('Paypal error: (invalid address or customer)'));
}
// check currency of payment
if ($currency_order->id != $currency_module->id) {
$cookie->id_currency = $currency_module->id;
$cart->id_currency = $currency_module->id;
$cart->update();
}
$smarty->assign(array('redirect_text' => $paypal->getL('Please wait, redirecting to Paypal... Thanks.'), 'cancel_text' => $paypal->getL('Cancel'), 'cart_text' => $paypal->getL('My cart'), 'return_text' => $paypal->getL('Return to shop'), 'paypal_url' => $paypal->getPaypalStandardUrl(), 'address' => $address, 'country' => $country, 'state' => $state, 'amount' => (double) $cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), 'customer' => $customer, 'total' => (double) $cart->getOrderTotal(true, Cart::BOTH), 'shipping' => Tools::ps_round((double) $cart->getOrderShippingCost() + (double) $cart->getOrderTotal(true, Cart::ONLY_WRAPPING), 2), 'discount' => $cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS), 'business' => $business, 'currency_module' => $currency_module, 'cart_id' => (int) $cart->id . '_' . pSQL($cart->secure_key), 'products' => $cart->getProducts(), 'paypal_id' => (int) $paypal->id, 'header' => $header, 'url' => Tools::getShopDomain(true, true) . __PS_BASE_URI__));
if (is_file(_PS_THEME_DIR_ . 'modules/paypal/standard/redirect.tpl')) {
$smarty->display(_PS_THEME_DIR_ . 'modules/' . $paypal->name . '/standard/redirect.tpl');
} else {
$smarty->display(_PS_MODULE_DIR_ . $paypal->name . '/standard/redirect.tpl');
}
示例14: displayMain
public function displayMain()
{
global $cookie;
/*
when user add or change address,from addressView or joinView
*/
if (isset($_GET['ajaxStates']) and isset($_GET['id_country'])) {
$states = Db::getInstance()->getAll('
SELECT s.id_state, s.name
FROM ' . DB_PREFIX . 'state s
LEFT JOIN ' . DB_PREFIX . 'country c ON (s.`id_country` = c.`id_country`)
WHERE s.id_country = ' . (int) Tools::G('id_country') . ' AND s.active = 1 AND c.`need_state` = 1
ORDER BY s.`name` ASC');
if (is_array($states) and !empty($states)) {
$list = '';
if (Tools::G('no_empty') != true) {
$list = '<option value="0">-----------</option>' . "\n";
}
foreach ($states as $state) {
$list .= '<option value="' . (int) $state['id_state'] . '"' . (Tools::G('id_state') == $state['id_state'] ? ' selected="selected"' : '') . '>' . $state['name'] . '</option>' . "\n";
}
} else {
$list = 'false';
}
die($list);
}
//end get states
/*
from cartView get total
*/
if (isset($_GET['getTotal']) and isset($_GET['id_cart']) and isset($_GET['id_carrier'])) {
$carrier = new Carrier((int) $_GET['id_carrier']);
$cart = new Cart((int) $_GET['id_cart']);
$shipping = $carrier->shipping;
$p_total = $cart->getProductTotal();
$total = $shipping + $p_total - $cart->discount;
$arr = array('name' => $carrier->name, 'shipping' => Tools::displayPrice($shipping), 'total' => Tools::displayPrice($total));
echo json_encode($arr);
exit;
}
//end use gettotal
/*
start use promo code,from CartView
*/
if (isset($_GET['validatedPromocode']) && isset($_GET['code'])) {
if (!isset($cookie->id_cart)) {
$arr = array('status' => "NO", 'msg' => "cart is not init!");
echo json_encode($arr);
exit;
}
$row = Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'coupon WHERE code="' . pSQL($_GET['code']) . '" AND active=1');
if ($row) {
if ($row['id_user'] == 0 || $row['id_user'] == @$cookie->id_user) {
$cart = new Cart($cookie->id_cart);
$total = $cart->getProductTotal();
$quantity = $cart->getProductQantity();
$discount = 0;
if ($total > $row['total_over'] || $row['quantity_over'] > 0 && $quantity > $row['quantity_over']) {
if ($row['off'] > 0) {
$discount = (double) $total * $row['off'] / 100;
} else {
$discount = (double) $row['amount'];
}
$cart->discount = $discount;
if ($cart->update()) {
$arr = array('status' => "YES", 'discount' => "-" . Tools::displayPrice($discount), 'total' => Tools::displayPrice($cart->getOrderTotal()));
echo json_encode($arr);
exit;
}
}
}
}
$arr = array('status' => "NO", 'msg' => "the code don't found!");
echo json_encode($arr);
exit;
}
//end use promo code
/**
* 购物车
*/
if (Tools::G('c') == 'Cart') {
global $cart;
switch (Tools::G('m')) {
case 'removeItem':
if ($cart->deleteProduct(Tools::G('id'))) {
$cart_info = $cart->getCartInfo();
$result = array('status' => 'yes', 'cart_total' => Tools::displayPrice($cart_info['cart_total']), 'cart_quantity' => $cart_info['cart_quantity']);
die(json_encode($result));
}
die(json_encode(array("status" => "no")));
break;
case 'plusItem':
if ($row = $cart->plusProduct(Tools::G('id'))) {
$cart_info = $cart->getCartInfo();
$result = array('status' => 'yes', 'cart_total' => Tools::displayPrice($cart_info['cart_total']), 'cart_quantity' => $cart_info['cart_quantity'], 'item' => array('quantity' => $row['quantity'], 'total' => Tools::displayPrice($row['total'])));
die(json_encode($result));
}
die(json_encode(array("status" => "no")));
break;
case 'minusItem':
//.........这里部分代码省略.........
示例15: _changeCartGoodsNum
protected function _changeCartGoodsNum($uid, $goods_id, $old_goods_num, $goods_num, $indecr = '+')
{
if ($indecr === '-') {
$data['goods_num'] = $old_goods_num - $goods_num;
} elseif ($indecr === '+') {
$data['goods_num'] = $old_goods_num + $goods_num;
}
//获取商品数量,购物车的商品数量是否超出库存
$goods_info = AdminGoodsM::getGoodsInfoByGoodsId($goods_id);
if ($goods_info['goods_num'] < $data['goods_num']) {
$data['goods_num'] = $goods_info['goods_num'];
}
$where['goods_id'] = $goods_id;
//是否登录的条件
$_where = self::_where($uid);
$new_where = array_merge($where, $_where);
return Cart::update($data, $new_where);
}