Jump to content
Sign in to follow this  
tzunami

Actual Attribute Price (AAP v1.0b) Subtotal Error

Recommended Posts

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

Share this post


Link to post
Share on other sites

Yep,

 

I've (or rather our programmer!) has found the solution -

I'll be posting it as a mod soon...

Left the fix on my work PC - so i'll send you the fix tomorrow,

If you really need it sorted today I might be able to FTP the relevant section?

 

Tom

Share this post


Link to post
Share on other sites

The fix is ready...

 

Hopefully sort things out for you, but i'm no programmer! - you'll have to un-install the original mod and put this one in.

 

Let me know how you get on...

 

Tom

Share this post


Link to post
Share on other sites

There is a contribution that will sort that out - I think it's called something like "Attribute Sort"

Tom

Share this post


Link to post
Share on other sites

having installed the latest contribution have the problem again where the shopping cart total is incorrect.

Sorry tom ... thanks for the help you've been giving

Share this post


Link to post
Share on other sites

Sorry nainesh - been looking into it, but can't seem to figure out what is causing your errors :-(

Share this post


Link to post
Share on other sites

still got probs with discounted prices not showing their proper value, when using actual attributes.

(see previous message)

 

nainesh

Share this post


Link to post
Share on other sites

hello i am have the same prob with:

 

The total is wrong, the sub-total is right??

 

Someone help please??


jon lawrence

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×