函数function remove($products_id)
该函数的作用是删除购物车里面的一个商品,输入参数为商品ID。操作的表为:customers_basket 和 customers_basket_attributes。
删除数据库的操作是针对登录的用户,只有登录后才会记录当前用户的购物车内容。所以在删除数据库的记录的时候有一个判断if ($_SESSION[‘customer_id’]) function remove($products_id) {
global $db;
$this->notify('NOTIFIER_CART_REMOVE_START');
//die($products_id);
//CLR 030228 add call zen_get_uprid to correctly format product ids containing quotes
// $products_id = zen_get_uprid($products_id, $attributes);
unset($this->contents[$products_id]);///从购物车内删除
// remove from database
if ($_SESSION['customer_id']) {
// zen_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . zen_db_input($products_id) . "'");///从数据库中删除
$sql = "delete from " . TABLE_CUSTOMERS_BASKET . "
where customers_id = '" . (int)$_SESSION['customer_id'] . "'
and products_id = '" . zen_db_input($products_id) . "'";
$db->Execute($sql);
// zen_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . zen_db_input($products_id) . "'");
$sql = "delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . "
where customers_id = '" . (int)$_SESSION['customer_id'] . "'
and products_id = '" . zen_db_input($products_id) . "'";
$db->Execute($sql);
}
// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
$this->cartID = $this->generate_cart_id();
$this->notify('NOTIFIER_CART_REMOVE_END');
}