Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product Attribute Multiplier Error Please Help


oscommerceking

Recommended Posts

i was having trouble with finding a multiplier for the base price instead of just a + or a -

 

then i found the module

 

http://www.oscommerce.com/community/contri...arch,multiplier

 

However when i enter 1.2 * in for the product multiplier ( with a base value of say 10$ ) the total comes to $12, and the sub total $12

 

But wait, when i change the qty to 2, the total comes to $24 and the sub total comes to $48

 

Please help here is the code from the modifications i did in the module above

 

vi catalog/includes/classes/shopping_cart.php

find: // attributes price
replace:
           if ($attribute_price['price_prefix'] == '+') {
             $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           } else {
             $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           }
with:
           if ($attribute_price['price_prefix'] == '+') {
             $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           } elseif ($attribute_price['price_prefix'] == '-') {
             $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           } elseif ($attribute_price['price_prefix'] == '*') {
             $this->total = $this->total * $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           }

find: function attributes_price
replace:
   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);
         if ($attribute_price['price_prefix'] == '+') {
           $attributes_price += $attribute_price['options_values_price'];
         } else {
           $attributes_price -= $attribute_price['options_values_price'];
         }
with:

   function attributes_price($products_id, $products_price) {
     $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);
         if ($attribute_price['price_prefix'] == '+') {
             $attributes_price += $attribute_price['options_values_price'];
         } elseif ($attribute_price['price_prefix'] == '-') {
             $attributes_price -= $attribute_price['options_values_price'];
         } elseif ($attribute_price['price_prefix'] == '*') {
             $attributes_price = ($products_price * $attribute_price['options_values_price'])-$products_price;
         }

find:         $products_array[] = array('id' => $products_id,
replace: 
 'final_price' => ($products_price + $this->attributes_price($products_id)),
with:
'final_price' => ($products_price + $this->attributes_price($products_id, $products_price)),

 

 

thanx in advance :thumbsup:

 

J

Link to comment
Share on other sites

Here is the answer to my own question and hopefully this helps out someone

 

$this->total = $this->total * $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);

 

Should be replaced with

 

 $this->total = $this->total * tep_add_tax($attribute_price['options_values_price'], $products_tax);

 

Thanks for all your input and efforts , you all truly make this a wonderful and informative ecommerce community

 

J

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...