本文整理汇总了PHP中Cart::deleteProduct方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart::deleteProduct方法的具体用法?PHP Cart::deleteProduct怎么用?PHP Cart::deleteProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart
的用法示例。
在下文中一共展示了Cart::deleteProduct方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionDelete
public function actionDelete($productId)
{
Cart::deleteProduct($productId);
// redirect to previous page
$referer = $_SERVER['HTTP_REFERER'];
header("Location: {$referer}");
}
示例2: actionDelete
/**
* Action для добавления товара в корзину синхронным запросом
* @param integer $id <p>id товара</p>
*/
public function actionDelete($id)
{
// Удаляем заданный товар из корзины
Cart::deleteProduct($id);
// Возвращаем пользователя в корзину
header("Location: /cart");
}
示例3: 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':
//.........这里部分代码省略.........
示例4: actionDelete
public function actionDelete($id)
{
Cart::deleteProduct($id);
return true;
}
示例5: Cart
<?php
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>";
}
}
示例6: hookExtraCarrier
public function hookExtraCarrier($params)
{
global $smarty, $cookie;
//delete overcost product if exist
$cart = new Cart(intval($params['cart']->id));
$products = $cart->getProducts(false);
$ids = array();
foreach ($products as $product) {
$ids[] .= intval($product['id_product']);
}
if (in_array(Configuration::get('SOCOLISSIMO_PRODUCT_ID'), $ids)) {
$cart->deleteProduct(Configuration::get('SOCOLISSIMO_PRODUCT_ID'));
}
$cart->update();
$country = new Country(intval($params['address']->id_country));
$customer = new Customer($params['address']->id_customer);
$gender = array('1' => 'MR', '2' => 'MME');
if (in_array(intval($customer->id_gender), array(1, 2))) {
$cecivility = $gender[intval($customer->id_gender)];
} else {
$cecivility = 'MR';
}
$carrierSo = new Carrier(intval(Configuration::get('SOCOLISSIMO_CARRIER_ID')));
if (isset($carrierSo) and $carrierSo->active) {
$signature = $this->make_key(substr($this->lower($params['address']->lastname), 0, 34), (int) Configuration::Get('SOCOLISSIMO_PREPARATION_TIME'), number_format((double) $params['cart']->getOrderShippingCost($carrierSo->id, true), 2, ',', ''), (int) $params['address']->id_customer, (int) $params['address']->id);
if (Configuration::Get('SOCOLISSIMO_COST_SELLER') && Configuration::get('SOCOLISSIMO_CARRIER_ID_SELLER')) {
$seller_cost = number_format((double) $params['cart']->getOrderShippingCost((int) Configuration::get('SOCOLISSIMO_CARRIER_ID_SELLER')), 2, ',', '');
} else {
$seller_cost = 0;
}
$orderId = $this->formatOrderId((int) $params['address']->id);
// Keep this fields order (see doc.)
$inputs = array('pudoFOId' => Configuration::get('SOCOLISSIMO_ID'), 'ceName' => $this->replaceAccentedChars(substr($params['address']->lastname, 0, 34)), 'dyPreparationTime' => (int) Configuration::Get('SOCOLISSIMO_PREPARATION_TIME'), 'dyForwardingCharges' => number_format((double) $params['cart']->getOrderShippingCost($carrierSo->id), 2, ',', ''), 'dyForwardingChargesCMT' => $seller_cost, 'trClientNumber' => $this->upper((int) $params['address']->id_customer), 'orderId' => $orderId, 'numVersion' => $this->getNumVersion(), 'ceCivility' => $cecivility, 'ceFirstName' => $this->replaceAccentedChars(substr($params['address']->firstname, 0, 29)), 'ceCompanyName' => $this->replaceAccentedChars(substr($params['address']->company, 0, 38)), 'ceAdress3' => $this->replaceAccentedChars(substr($params['address']->address1, 0, 38)), 'ceAdress4' => $this->replaceAccentedChars(substr($params['address']->address2, 0, 38)), 'ceZipCode' => $this->replaceAccentedChars($params['address']->postcode), 'ceTown' => $this->replaceAccentedChars(substr($params['address']->city, 0, 32)), 'ceEmail' => $this->replaceAccentedChars($params['cookie']->email), 'cePhoneNumber' => $this->replaceAccentedChars(str_replace(array(' ', '.', '-', ',', ';', '+', '/', '\\', '+', '(', ')'), '', $params['address']->phone_mobile)), 'dyWeight' => (double) $params['cart']->getTotalWeight() * 1000, 'trParamPlus' => (int) $carrierSo->id, 'trReturnUrlKo' => htmlentities($this->url, ENT_NOQUOTES, 'UTF-8'), 'trReturnUrlOk' => htmlentities($this->url, ENT_NOQUOTES, 'UTF-8'), 'CHARSET' => 'UTF-8', 'cePays' => $country->iso_code, 'trInter' => Configuration::get('SOCOLISSIMO_EXP_BEL'), 'ceLang' => 'FR');
$row['id_carrier'] = intval($carrierSo->id);
if (!$inputs['dyForwardingChargesCMT']) {
unset($inputs['dyForwardingChargesCMT']);
}
$std_cost = number_format((double) $params['cart']->getOrderShippingCost($carrierSo->id), 2, ',', '');
$from_cost = $std_cost;
if ($seller_cost) {
if ((double) str_replace(',', '.', $seller_cost) < (double) str_replace(',', '.', $std_cost)) {
$from_cost = $seller_cost;
}
}
$smarty->assign(array('select_label' => $this->l('Select delivery mode'), 'edit_label' => $this->l('Edit delivery mode'), 'token' => sha1('socolissimo' . _COOKIE_KEY_ . $params['cart']->id), 'urlSo' => Configuration::get('SOCOLISSIMO_URL') . '?trReturnUrlKo=' . htmlentities($this->url, ENT_NOQUOTES, 'UTF-8'), 'id_carrier' => intval($row['id_carrier']), 'id_carrier_seller' => Configuration::get('SOCOLISSIMO_CARRIER_ID_SELLER'), 'SOBWD_C' => false, 'inputs' => $inputs, 'initialCost' => $this->l('From') . ' ' . $from_cost . ' €', 'finishProcess' => $this->l('To choose SoColissimo, click on a delivery method')));
$carriers = Carrier::getCarriers($cookie->id_lang, false);
foreach ($carriers as $carrier) {
$ids[] .= $carrier['id_carrier'];
}
if ($country->iso_code == 'FR' || $country->iso_code == 'BE' && Configuration::get('SOCOLISSIMO_EXP_BEL') and Configuration::Get('SOCOLISSIMO_ID') != NULL and Configuration::get('SOCOLISSIMO_KEY') != NULL and $this->checkAvailibility() and $this->checkSoCarrierAvailable(intval(Configuration::get('SOCOLISSIMO_CARRIER_ID'))) and in_array(intval(Configuration::get('SOCOLISSIMO_CARRIER_ID')), $ids)) {
return $this->display(__FILE__, 'socolissimo_iframe.tpl');
} else {
$smarty->assign('ids', explode('|', Configuration::get('SOCOLISSIMO_CARRIER_ID_HIST')));
return $this->display(__FILE__, 'socolissimo_error.tpl');
}
}
}
示例7: actionDelete
/**
* @param $id
* Метод для удаления определенного товара из корзины
*/
public function actionDelete($id)
{
return Cart::deleteProduct($id);
header("Location: /cart");
//остаемся в разделе Корзина
}
示例8: actionDelete
public function actionDelete($id)
{
Cart::deleteProduct($id);
FunctionLibrary::redirectTo('/cart');
}