📄 shopping_cart.php
字号:
function get_product_id_list() {
$product_id_list = '';
if (is_array($this->contents))
{
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
$product_id_list .= ', ' . $products_id;
}
}
return substr($product_id_list, 2);
}
function calculate() {
$this->total = 0;
$this->weight = 0;
if (!is_array($this->contents)) return 0;
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
$qty = $this->contents[$products_id]['qty'];
// products price
$product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id='" . tep_get_prid($products_id) . "'");
if ($product = tep_db_fetch_array($product_query)) {
// ICW ORDER TOTAL CREDIT CLASS Start Amendment
$no_count=1;
$gv_query=tep_db_query("select products_model from ".TABLE_PRODUCTS." where products_id='".$products_id."'");
$gv_result=tep_db_fetch_array($gv_query);
if (ereg('^GIFT', $gv_result['products_model'])) {
$no_count=0;
}
// ICW ORDER TOTAL CREDIT CLASS End Amendment
$prid = $product['products_id'];
$products_tax = tep_get_tax_rate($product['products_tax_class_id']);
$products_price = $product['products_price'];
$products_weight = $product['products_weight'];
$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $prid . "' and status = '1'");
if (tep_db_num_rows ($specials_query)) {
$specials = tep_db_fetch_array($specials_query);
$products_price = $specials['specials_new_products_price'];
}
$this->total += tep_add_tax($products_price, $products_tax) * $qty;
$this->weight += ($qty * $products_weight);
$this->total_virtual += tep_add_tax($products_price, $products_tax) * $qty*$no_count;// CREDIT CLASS;
$this->weight_virtual += ($qty * $products_weight)*$no_count;// CREDIT CLASS;
}
// attributes price
if ($this->contents[$products_id]['attributes']) {
reset($this->contents[$products_id]['attributes']);
while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
$attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $prid . "' and options_id = '" . $option . "' and options_values_id = '" . $value . "'");
$attribute_price = tep_db_fetch_array($attribute_price_query);
if ($attribute_price['price_prefix'] == '+') {
$this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
} else {
$this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
}
}
}
}
}
function attributes_price($products_id) {
if ($this->contents[$products_id]['attributes']) {
reset($this->contents[$products_id]['attributes']);
while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
$attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $products_id . "' and options_id = '" . $option . "' and options_values_id = '" . $value . "'");
$attribute_price = tep_db_fetch_array($attribute_price_query);
if ($attribute_price['price_prefix'] == '+') {
$attributes_price += $attribute_price['options_values_price'];
} else {
$attributes_price -= $attribute_price['options_values_price'];
}
}
}
return $attributes_price;
}
function get_products() {
global $languages_id;
if (!is_array($this->contents)) return 0;
$products_array = array();
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id='" . tep_get_prid($products_id) . "' and pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "'");
if ($products = tep_db_fetch_array($products_query)) {
$prid = $products['products_id'];
$products_price = $products['products_price'];
$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $prid . "' and status = '1'");
if (tep_db_num_rows($specials_query)) {
$specials = tep_db_fetch_array($specials_query);
$products_price = $specials['specials_new_products_price'];
}
$products_array[] = array('id' => $products_id,
'name' => $products['products_name'],
'model' => $products['products_model'],
'price' => $products_price,
'quantity' => $this->contents[$products_id]['qty'],
'weight' => $products['products_weight'],
'final_price' => ($products_price + $this->attributes_price($products_id)),
'tax_class_id' => $products['products_tax_class_id'],
'attributes' => $this->contents[$products_id]['attributes']);
}
}
return $products_array;
}
function show_total() {
$this->calculate();
return $this->total;
}
function show_weight() {
$this->calculate();
return $this->weight;
}
// CREDIT CLASS Start Amendment
function show_total_virtual() {
$this->calculate();
return $this->total_virtual;
}
function show_weight_virtual() {
$this->calculate();
return $this->weight_virtual;
}
// CREDIT CLASS End Amendment
function unserialize($broken) {
for(reset($broken);$kv=each($broken);) {
$key=$kv['key'];
if (gettype($this->$key)!="user function")
$this->$key=$kv['value'];
}
}
// ------------------------ ICWILSON Gift Voucher Addittion-------------------------------Start
// amend count_contents to show nil contents for shipping
// as we don't want to quote for 'virtual' item
// GLOBAL CONSTANTS if NO_COUNT_ZERO_WEIGHT is true then we don't count any product with a weight
// which is less than or equal to MINIMUM_WEIGHT
// otherwise we just don't count gift certificates
function count_contents_virtual() { // get total number of items in cart disregard gift vouchers
$total_items = 0;
if (is_array($this->contents)) {
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
$no_count=false;
$gv_query=tep_db_query("select products_model from ".TABLE_PRODUCTS." where products_id='".$products_id."'");
$gv_result=tep_db_fetch_array($gv_query);
if (ereg('^GIFT', $gv_result['products_model'])) {
$no_count=true;
}
if (NO_COUNT_ZERO_WEIGHT==1) {
$gv_query = tep_db_query("select products_weight from " . TABLE_PRODUCTS . " where products_id='" . tep_get_prid($products_id) . "'");
$gv_result=tep_db_fetch_array($gv_query);
if ($gv_result['products_weight']<=MINIMUM_WEIGHT) {
$no_count=true;
}
}
if ($no_count==false) $total_items += $this->get_quantity($products_id);
}
}
return $total_items;
}
// ------------------------ ICWILSON Gift Voucher Addittion-------------------------------End
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -