global $customer_id;
if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true..
$this->contents[$products_id][$price] = array('qty' => $quantity);
$price_temp = explode(".",$price);
if (count($price_temp)==2)
$price_temp[1] = substr($price_temp[1],0,4);
$price2 = implode($price_temp,".");
//echo "update `" . TABLE_CUSTOMERS_BASKET . "` set customers_basket_quantity = '" . $quantity . "' where products_id = '" . tep_db_input($products_id) . "' AND customers_id = '" . (int)$customer_id . "' AND products_price = '" . tep_db_input($price) . "'";
// update database
if (tep_session_is_registered('customer_id')){
tep_db_query("update `" . TABLE_CUSTOMERS_BASKET . "` set customers_basket_quantity = '" . $quantity . "' where products_id = '" . tep_db_input($products_id) . "' AND customers_id = '" . (int)$customer_id . "' AND products_price = '" . tep_db_input($price2) . "';");
}
if (is_array($attributes)) {
reset($attributes);
while (list($option, $value) = each($attributes)) {
$this->contents[$products_id][$price]['attributes'][$option] = $value;
// update database
if (tep_session_is_registered('customer_id')){
tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "' and products_price = '" . tep_db_input($price2) . "'");
}
}
}
Partager