Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

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


tzunami

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

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...