i also performed a line by line compare of shopping_cart_backup.php to shopping_cart_dp.php (copied and renamed for the purpose of the compare). These will be different but maybe you can spot where different variables are used:
backup file
Code:
The following values are only in G:\shopping_cart_backup.php.
* @copyright Copyright 2003-2007 Zen Cart Development Team
* @version $Id: shopping_cart.php 7276 2007-10-23 05:36:08Z drbyte $
$qty = $this->adjust_quantity($qty, $products_id, 'shopping_cart');
$this->contents[$products_id] = array('qty' => (float)$qty);
$this->contents[$products_id] = array('qty' => (float)$quantity);
* Method to check whether a product exists in the cart
$product_query = "select products_id, products_price, products_tax_class_id, products_weight,
$products_price = $product->fields['products_price'];
$products_price = $product->fields['products_price'];
if ($product->fields['product_is_always_free_shipping'] == '1' or $product->fields['products_virtual'] == '1') {
$shipping_attributes_price = zen_get_discount_calc($product->fields['products_id'], $attribute_price->fields['products_attributes_id'], $attribute_price->fields['options_values_price'], $qty);
$this->free_shipping_price -= $qty * zen_add_tax( ($shipping_attributes_price), $products_tax);
$this->total -= $qty * zen_add_tax($attribute_price->fields['options_values_price'], $products_tax);
$this->free_shipping_price += $qty * zen_add_tax( ($shipping_attributes_price), $products_tax);
$this->total += $qty * zen_add_tax($attribute_price->fields['options_values_price'], $products_tax);
} // eof: attribute price
// do not count download as free when set to product/download combo
if ($adjust_downloads == 1 and $product->fields['product_is_always_free_shipping'] != 2) {
// echo 'I SEE ' . $this->total . ' vs ' . $this->free_shipping_price . ' items: ' . $this->free_shipping_item. '<br>';
$new_attributes_price = zen_get_discount_calc($products_id, $attribute_price->fields['products_attributes_id'], $attribute_price->fields['options_values_price'], $qty);
$attributes_price += $attribute_price->fields['options_values_price'];
$new_attributes_price = zen_get_discount_calc($products_id, $attribute_price->fields['products_attributes_id'], $attribute_price->fields['options_values_price'], $qty);
p.products_price, p.products_weight, p.products_tax_class_id,
$products_price = $products->fields['products_price'];
$products_price = $products->fields['products_price'];
$check_unit_decimals = zen_get_products_quantity_order_units((int)$products->fields['products_id']);
if (strstr($check_unit_decimals, '.')) {
$new_qty = round($new_qty, QUANTITY_DECIMALS);
$new_qty = round($new_qty, 0);
'name' => $products->fields['products_name'],
'model' => $products->fields['products_model'],
'image' => $products->fields['products_image'],
'price' => ($products->fields['product_is_free'] =='1' ? 0 : $products_price),
'quantity' => $new_qty,
'weight' => $products->fields['products_weight'] + $this->attributes_weight($products_id),
// fix here
'final_price' => ($products_price + $this->attributes_price($products_id)),
'onetime_charges' => ($this->attributes_price_onetime_charges($products_id, $new_qty)),
'tax_class_id' => $products->fields['products_tax_class_id'],
'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''),
'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''),
'products_priced_by_attribute' => $products->fields['products_priced_by_attribute'],
'product_is_free' => $products->fields['product_is_free'],
'products_discount_type' => $products->fields['products_discount_type'],
'products_discount_type_from' => $products->fields['products_discount_type_from']);
$free_ship_check = $db->Execute("select products_virtual, products_model, products_price, product_is_always_free_shipping from " . TABLE_PRODUCTS . " where products_id = '" . zen_get_prid($products_id) . "'");
. TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
if ($free_ship_check->fields['products_virtual'] == '1') {
$this->content_type = 'virtual';
$this->content_type = 'mixed';
if ($gv_only == 'true') {
return $gift_voucher;
} else {
return $this->content_type;
}
//echo 'I SEE actionUpdateProduct: ' . $_POST['products_id'] . ' ' . $_POST['products_id'][$i] . '<br>';
$new_qty = $this->adjust_quantity($new_qty, $_POST['products_id'][$i], 'shopping_cart');
// $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . ' A: - ' . zen_get_products_name($_POST['products_id'][$i]), 'caution');
$messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . zen_get_products_name($_POST['products_id'][$i]), 'caution');
// display message if all is good and not on shopping_cart page
if (DISPLAY_CART == 'false' && $_GET['main_page'] != FILENAME_SHOPPING_CART) {
$messageStack->add_session('header', SUCCESS_ADDED_TO_CART_PRODUCT, 'success');
//echo 'I SEE actionAddProduct: ' . $_POST['products_id'] . '<br>';
$new_qty = $this->adjust_quantity($new_qty, $_POST['products_id'], 'shopping_cart');
// $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . ' B: - ' . zen_get_products_name($_POST['products_id']), 'caution');
$messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . zen_get_products_name($_POST['products_id']), 'caution');
if (DISPLAY_CART == 'false' && $_GET['main_page'] != FILENAME_SHOPPING_CART) {
$messageStack->add_session('header', SUCCESS_ADDED_TO_CART_PRODUCT, 'success');
if (DISPLAY_CART == 'false' && $_GET['main_page'] != FILENAME_SHOPPING_CART) {
$messageStack->add_session('header', SUCCESS_ADDED_TO_CART_PRODUCT, 'success');
// zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters)));
zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters, $products_id) . 'products_id=' . $_GET['products_id']));
* @todo change while loop to a foreach
if (is_array($_POST['products_id']) && sizeof($_POST['products_id']) > 0) {
foreach($_POST['products_id'] as $key=>$val) {
// while ( list( $key, $val ) = each($_POST['products_id']) ) {
if ($val > 0) {
$adjust_max = false;
$prodId = $key;
$qty = $val;
$add_max = zen_get_products_quantity_order_max($prodId);
$cart_qty = $this->in_cart_mixed($prodId);
// $new_qty = $qty;
//echo 'I SEE actionMultipleAddProduct: ' . $prodId . '<br>';
$new_qty = $this->adjust_quantity($qty, $prodId, 'shopping_cart');
if (($add_max == 1 and $cart_qty == 1)) {
// do not add
// adjust quantity if needed
if (($new_qty + $cart_qty > $add_max) and $add_max != 0) {
$adjust_max= 'true';
$new_qty = $add_max - $cart_qty;
$this->add_cart($prodId, $this->get_quantity($prodId)+($new_qty));
if ($adjust_max == 'true') {
// $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . ' C: - ' . zen_get_products_name($prodId), 'caution');
$messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . zen_get_products_name($prodId), 'caution');
$messageStack->add_session('header', SUCCESS_ADDED_TO_CART_PRODUCTS, 'success');
// $qty = $this->adjust_quantity($qty, (int)$products_id, 'shopping_cart');
// temporary fixed on messagestack used for check and message needs better separation
function adjust_quantity($check_qty, $products, $message=false) {
$old_quantity = $check_qty;
$fix_qty = $check_qty;
// $messageStack->add_session('shopping_cart', ERROR_QUANTITY_ADJUSTED . zen_get_products_name($products) . ' - ' . $old_quantity . ' => ' . $new_qty, 'caution');
$new_qty = preg_replace('/[0]+$/','', $check_qty);
// $messageStack->add_session('shopping_cart', 'A: ' . ERROR_QUANTITY_ADJUSTED . zen_get_products_name($products) . ' - ' . $old_quantity . ' => ' . $new_qty, 'caution');
if ($check_qty != round($check_qty, QUANTITY_DECIMALS)) {
$new_qty = round($check_qty, QUANTITY_DECIMALS);
$messageStack->add_session('shopping_cart', ERROR_QUANTITY_ADJUSTED . zen_get_products_name($products) . ERROR_QUANTITY_CHANGED_FROM . $old_quantity . ERROR_QUANTITY_CHANGED_TO . $new_qty, 'caution');
$new_qty = $check_qty;
return $new_qty;
new file
Code:
The following values are only in G:\shopping_cart_dp.php.
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @version $Id: shopping_cart.php 3856 2006-06-29 02:26:33Z drbyte $
$this->contents[$products_id] = array('qty' => $qty);
$this->contents[$products_id] = array('qty' => $quantity);
* Method to check wheter a product exists in the cart
$product_query = "select products_id, products_price, products_price_w, products_tax_class_id, products_weight,
// $products_price = $product->fields['products_price']; - REMOVED FOR DUAL PRICING MOD
//*************************************************************
//***** CHECK WHETHER WHOLESALE OR RETAIL AND GET CORRECT PRICE
if ($_SESSION['customer_id']) {
$customers_id = $_SESSION['customer_id'];
$customer_check = $db->Execute("select * from " . TABLE_CUSTOMERS . " where customers_id = '$customers_id'");
if ($customer_check->fields['customers_whole'] != "0") {
$i = $customer_check->fields['customers_whole'];
$i = $i-1;
$products_price_array = $product->fields['products_price_w'];
$productsprice = explode("-",$products_price_array);
$products_price = $productsprice[$i];
if ($products_price == '0' || $products_price == '') {
$products_price = $productsprice[0];
}
if ($products_price=='0'){
$products_price = $product->fields['products_price'];
} else {
$products_price = $product->fields['products_price'];
}
} else {
$products_price = $product->fields['products_price'];
//****************************************************************
//*****END CHECK WHETHER WHOLESALE OR RETAIL AND GET CORRECT PRICE
$products_price = $products_price;
$customers_id = $_SESSION['customer_id'];
if ($customer_check->fields['customers_whole'] != "0") {
$i = $customer_check->fields['customers_whole'];
$i = $i-1;
$attribute_cost_array = $attribute_price->fields['options_values_price_w'];
$attributeprice = explode(",",$attribute_cost_array);
$attribute_cost = $attributeprice[$i];
if ($attribute_cost=='0' || $attribute_cost=='') {
$attribute_cost = $attributeprice[0];
if ($attribute_cost =='0'){
$attribute_cost = $attribute_price->fields['options_values_price'];
} else {
$attribute_cost = $attribute_price->fields['options_values_price'];
}
$attribute_cost = $attribute_price->fields['options_values_price'];
// $this->free_shipping_price -= $qty * zen_add_tax( ($new_attributes_price), $products_tax);
//$this->total -= $qty * zen_add_tax($attribute_price->fields['options_values_price'], $products_tax);
$this->total -= $qty * zen_add_tax($attribute_cost, $products_tax);
$new_attributes_price = zen_get_discount_calc($product->fields['products_id'], $attribute_price->fields['products_attributes_id'], $attribute_cost, $qty);
// $this->free_shipping_price += $qty * zen_add_tax( ($new_attributes_price), $products_tax);
//$this->total += $qty * zen_add_tax($attribute_price->fields['options_values_price'], $products_tax);
$this->total += $qty * zen_add_tax($attribute_cost, $products_tax);
if ($adjust_downloads == 1) {
//****************************************************************
$new_attributes_price = zen_get_discount_calc($products_id, $attribute_price->fields['products_attributes_id'], $attribute_cost, $qty);
$attributes_price += $attribute_cost;
$new_attributes_price = zen_get_discount_calc($products_id, $attribute_price->fields['products_attributes_id'], $attribute_cost, $qty);
p.products_price, p.products_price_w, p.products_weight, p.products_tax_class_id,
// $products_price = $product->fields['products_price']; - REMOVED FOR DUAL PRICING MOD
$products_price_array = $products->fields['products_price_w'];
$products_price = $products->fields['products_price'];
$products_price = $products->fields['products_price'];
$products_price = $products->fields['products_price'];
// $products_price = $product->fields['products_price']; - REMOVED FOR DUAL PRICING MOD
$new_qty = round($new_qty, QUANTITY_DECIMALS);
'name' => $products->fields['products_name'],
'model' => $products->fields['products_model'],
'image' => $products->fields['products_image'],
'price' => ($products->fields['product_is_free'] =='1' ? 0 : $products_price),
'quantity' => $new_qty,
'weight' => $products->fields['products_weight'] + $this->attributes_weight($products_id),
// fix here
'final_price' => ($products_price + $this->attributes_price($products_id)),
'onetime_charges' => ($this->attributes_price_onetime_charges($products_id, $new_qty)),
'tax_class_id' => $products->fields['products_tax_class_id'],
'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''),
'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''),
'products_priced_by_attribute' => $products->fields['products_priced_by_attribute'],
'product_is_free' => $products->fields['product_is_free'],
'products_discount_type' => $products->fields['products_discount_type'],
'products_discount_type_from' => $products->fields['products_discount_type_from']);
$free_ship_check = $db->Execute("select products_virtual, products_model, products_price, products_price_w, product_is_always_free_shipping from " . TABLE_PRODUCTS . " where products_id = '" . zen_get_prid($products_id) . "'");
. TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
$this->content_type = 'mixed';
if ($gv_only == 'true') {
return $gift_voucher;
return $this->content_type;
$this->content_type = 'virtual';
$messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . ' - ' . zen_get_products_name($_POST['products_id'][$i]), 'caution');
$messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . ' - ' . zen_get_products_name($_POST['products_id']), 'caution');
while ( list( $key, $val ) = each($_POST['products_id']) ) {
if ($val > 0) {
$prodId = $key;
$qty = $val;
$add_max = zen_get_products_quantity_order_max($prodId);
$cart_qty = $this->in_cart_mixed($prodId);
$new_qty = $qty;
$this->add_cart($prodId, $this->get_quantity($prodId)+($new_qty));
$messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . ' - ' . zen_get_products_name($prodId), 'caution');
Bookmarks