Hello!
This will be my first and probably the only contribution I will do on this forum, since my job doesn't allow me to distribute code\solutions provided by us, and since this is just a Patch, I will share it with you:
Zahid Hussain shared the code that worked:
"you want to edit this file: includes/classes/shopping_cart.php"
Find the following code (should be around line 1243):
And REPLACE with this:PHP Code:$products_array[] = array('id' => $products_id,
'category' => $products->fields['master_categories_id'],
'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' => $this->contents[$products_id]['qty'],
'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']);
}
}
$this->notify('NOTIFIER_CART_GET_PRODUCTS_END');
return $products_array;
}
The thing is that that code was delivering the base price + the price by Area;PHP Code://begin Attribute Calculator 1.0
//Zen Cart contribution by JT Website Design http://www.jtwebsitedesign.com
$description_sql = 'SELECT products_name FROM ' . TABLE_PRODUCTS_DESCRIPTION . ' where products_id = "' . (int) $products_id . '"';
$pdescription = $db->Execute($description_sql);
$products_name = $pdescription->fields['products_name'];
switch($products->fields['products_name'])
{
case 'Product A':
$priceFactor = 1.00;
break;
case 'Product B':
$priceFactor = 0.50;
break;
case 'Product C':
$priceFactor = 1.25;
break;
default:
$priceFactor = 0;
}
if($priceFactor != 0)
{
$Length_ID_Query = "select products_options_id from " . TABLE_PRODUCTS_OPTIONS . " where products_options_name = 'Length'";
$Length_ID = $db->Execute($Length_ID_Query);
$LengthID = (int)$Length_ID->fields['products_options_id'];
$Width_ID_Query = "select products_options_id from " . TABLE_PRODUCTS_OPTIONS . " where products_options_name = 'Width'";
$Width_ID = $db->Execute($Width_ID_Query);
$WidthID = (int)$Width_ID->fields['products_options_id'];
if ($this->contents[$products_id]['attributes_values'][$WidthID] && $this->contents[$products_id]['attributes_values'][$LengthID])
$areaFactor = $this->contents[$products_id]['attributes_values'][$WidthID]*$this->contents[$products_id]['attributes_values'][$LengthID];
else
$areaFactor = 0;
$extraCharge = $areaFactor * $priceFactor;
}
else
$extraCharge = 0;
//end Attribute Calculator 1.0
$products_array[] = array('id' => $products_id,
'category' => $products->fields['master_categories_id'],
'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+$extraCharge),
// 'quantity' => $this->contents[$products_id]['qty'],
'quantity' => $new_qty,
'weight' => $products->fields['products_weight'] + $this->attributes_weight($products_id),
// fix here
'final_price' => ($products_price + $this->attributes_price($products_id) + $extraCharge),
'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']);
}
}
$this->notify('NOTIFIER_CART_GET_PRODUCTS_END');
return $products_array;
}
All I had to do was to replace
byPHP Code:$extraCharge = $areaFactor * $priceFactor
Not that so far this is the only free sollution working on an open-source e-commerce platform, thanks a lot to the creator and have fun coding.PHP Code:$extraCharge = $areaFactor * $priceFactor-$products_price;


Reply With Quote
