I have recently installed the Actual Attribute Price (AAP v1.0b) modification.
While the modification itself is very good (showing the actual prices of different selected attributes when there is no +/- prefix included).
Presently the code works as expected for everything except the Shopping Cart.
Example...
*For non-british users VAT is tax at 17.5%*
Product: Glass Top Tables/Pot Stands
Product Price: 64.95 Inc VAT (Exc 55.2766)
Attribute1: Size - Set of Both
Attribute Price: 55.2766
Attribute Price Inc VAT: 64.95
Attribute2: Size - Small
Attribute Price: 23.7872
Attribute Price Inc VAT: 27.95
Attribute3: Size - Large
Attribute Price: 34.0000
Attribute Price Inc VAT: 39.95
When I select attribute 1 from the drop-drown list and add to cart, everything works fine - the price of 64.95 displays correctly in the Shopping Cart, as does the subtotal of 64.95.
If instead I select attribute 2 or 3, the subtotal of the shopping cart is incorrect.
There seems no reasoning however for the value of the subtotal.
If in this example I have only the small option in the cart (attribute 2) the price displays (correctly) as 27.95, but the subtotal is displayed as 33.48 (when it should be 27.95)
With attribute 3 (large) only in the shopping cart, the price is correct (39.95), but the subtotal is again wrong (43.69) when it should be 39.95.
There seems no logic or reasoning to this, and hiding the shopping cart would be a very drastic measure for something that is probably very simple.
I have been looking everywhere for the answer, so if anyone has it then please please please help me out!
I've included the code from the two modified files
(I have also installed attribute sortv 1.0 if that helps anyone)
[THE FOLLOWING IS THE ADDED CODE FROM SHOPPING_CART.PHP
catalog/includes/classes/shopping_cart.php]
// BOF - AAP V1.0 - updated to account for no price prefix to equal actual price
// attributes price
if (isset($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 = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
$attribute_price = tep_db_fetch_array($attribute_price_query);
$price_prefix = $attribute_price['price_prefix'];
$option_price = $attribute_price['options_values_price'];
$products_query = tep_db_query("select products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
$products_stuff = tep_db_fetch_array($products_query);
$products_price = $products_stuff['products_price'];
if ($price_prefix == '+') {
$this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
}
if ($price_prefix == '-') {
$this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
}
if (($price_prefix == '') and ($option_price != 0)) {
if ($price_prefix == '') {
$this->total += $qty * tep_add_tax(tep_adjust_price($option_price, $products_price), $product_tax);
}
}
}
}
}
}
// subtotal function for attributes price
function attributes_price($products_id) {
$attributes_price = 0;
if (isset($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 = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
$attribute_price = tep_db_fetch_array($attribute_price_query);
$price_prefix = $attribute_price['price_prefix'];
$option_price = $attribute_price['options_values_price'];
$products_query = tep_db_query("select products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
$products_stuff = tep_db_fetch_array($products_query);
$products_price = $products_stuff['products_price'];
if ($price_prefix == '+') {
$attributes_price += $option_price;
}
if ($price_prefix == '-') {
$attributes_price -= $option_price;
}
if (($price_prefix == '') and ($option_price != 0)) {
$attributes_price += tep_adjust_price($option_price, $products_price);
}
}
}
return $attributes_price;
}
// EOF - AAP V1.0
[THE FOLLOWING IS THE ADDED CODE FROM GENERAL.PHP
/catalog/includes/functions/general.php]
// BOF AAP V1.0
// actual attribute price adjustment (used with no price prefix only)
function tep_adjust_price($attribute, $price) {
global $currencies;
$adjustment = ($attribute-$price);
return $adjustment;
}
//EOF AAP V1.0
Many thanks
Tom