Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

What does += mean?


Recommended Posts

Please help me out...


I'm trying to create a hack to allow products with price altering attributes to be put on special... Am going ok (about 1/4 of the way there), but am getting stuck with this step:


With the shopping cart, I have the total showing up correctly at the bottom of the cart (xx% of the real total), it's the price that shows up on the right next to each individual product that I can't figure out. I think it's something to do with this code: (taken from includes/classes/shopping_cart.php, note tahat I have actual attribte price and I'm using that almost exclusively)...


	   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);
	 if ($attribute_price['price_prefix'] == '') {
	   $attributes_price += ([color=#FF0000].6[/color]*($attribute_price['options_values_price']-$products_price));
	  }   elseif ($attribute_price['price_prefix'] == '+') {
		$attributes_price += $attribute_price['options_values_price'];
		 elseif ($attribute_price['price_prefix'] == '-') {
		$attributes_price -= $attribute_price['options_values_price'];


Where I have highlighted '0.6' is what I'm playing around with - I *think* that if I could get this to work with .6, I could change it to the special percentage that I want. However, at the moment, this is not working:

Original Price: $2

Sale price: $1.20 (40% off)

Price that is being shown on the right hand side: $1.68


I can't even figure out how this $1.68 is being calculated, have tried the .6 with/without 10% (thought it might be something ot do with the tax I have setup), but no joy. I've noticed the

$attributes_price +=

and am wondering if it has anything to do with that.


I'm at a bit of a standstill, does anyone have any suggestions?


Thanks heaps ppls!



Link to comment
Share on other sites

if ($attribute_price['price_prefix'] == '') {

$attributes_price += (.6*($attribute_price['options_values_price']-$products_price));

Ignore my ramblings... i didn't have the order of opperations right (would you believe I'm majoring in mathematics?!!!)


The above should read


if ($attribute_price['price_prefix'] == '') {
	   $attributes_price += (.6*$attribute_price['options_values_price'])-$products_price));


now to tackle the rest of the scripts...



Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...