Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Graduated Prices Product Multiplier Field


oscommerceking

Recommended Posts

Hi all if anyone knows where to point me in the right direction per module or just general forum discussion i would be most appreciative here is my dilemna

 

 

In the product attributes area there is only a + or -

 

 

However i need to add a * or a / so that it multiplies or divides or takes a certain percentage of the product if they select a certain attribute

 

say attribute Large would multiple the base price times 1.1

and attribute small would multiple the base price times .9

 

 

Any ideas??

 

 

Thanks in Advance :thumbsup:

Link to comment
Share on other sites

 

Thanks for the pointer however have you been able to successfuly emply this contribution i cant find this part in my shopping_cart.php file within my catalog directory.

 

  if ($attributes_exist == '1') {
       reset($cart->contents[$products[$i]['id']]['attributes']);
       //----------------bof
       $x_ctr = 0;
       //----------------eof
       while (list($option, $value) = each($cart->contents[$products[$i]['id']]['attributes'])) {
         $attributes = tep_db_query("select pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $products[$i]['id'] . "' and pa.options_id = '" . $option . "' and pa.options_values_id = '" . $value . "'");
         $attributes_values = tep_db_fetch_array($attributes);
         if ($attributes_values['options_values_price'] != '0') {
         //--------------------------------------------------bof
      if ($attributes_values['price_prefix'] != 'x') {
          $attributes_values['options_values_price'] = $products[$i]['quantity'] * $attributes_values['options_values_price'];                   
                 echo "\n" . '<br><small><i>' . $attributes_values['price_prefix'] . $currencies->display_price($attributes_values['options_values_price'],tep_get_tax_rate($products[$i]['tax_class_id'])) . '</i></small>';
       } else  {
                 $temp = $attributes_values['options_values_price'];
   $x_ctr = $x_ctr + 1;
   if ($x_ctr <= 1) {
      $attributes_values['options_values_price'] = $products[$i]['price'] * ($attributes_values['options_values_price']);
      $total_price = $attributes_values['options_values_price'];
        echo "\n" . '<br><small><i>' . '(cost ' . $attributes_values['price_prefix'] . ' ' . $temp . ') = ' . '</i></small>' . $currencies->display_price($attributes_values['options_values_price'],tep_get_tax_rate($products[$i]['tax_class_id']));
     } else {
        $attributes_values['options_values_price'] = $total_price * ($attributes_values['options_values_price']);
        $total_price = $attributes_values['options_values_price'];
                    echo "\n" . '<br><small><i>' . '(cost ' . $attributes_values['price_prefix'] . ' ' . $temp . ') = ' . '</i></small>' . $currencies->display_price($attributes_values['options_values_price'],tep_get_tax_rate($products[$i]['tax_class_id']));
     }  
       }
         //-------------------------------eof    
         }  else {
// Keep price aligned with corresponding option
            $attributes_values['options_values_price'] = $products[$i]['price']; 
            echo "\n" . '<br><small><i> </i></small>';
         }
       }
     }
//------display customer choosen option eof-----
     echo '</td>' . "\n";
     echo '          </tr>' . "\n";
   }

 

Thanks in advance

 

J

Link to comment
Share on other sites

The contrib must be for an old version of osc.  Ah well, anyone else who can help out?

 

Jeremy

 

 

 

ok 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

  • 3 weeks later...

Your fix was exactly what I was looking for! Thanks for posting it. Just wondering though, if you know of a quick fix for multiple multiplies? I know the multiplier works when you just have one attribute value to multiply, but I'm trying to use to multiplier for dimensions and it only multiplies the last attribute value you select.

 

If I select this for a product attribute (product is set to $1):

 

Height: 15 (*15)

Width: 7 (*7)

 

The product total will give me $7. Although the subtotal gives me $105, correctly. I proceeded toward the checkout to see which number will be used in the check out and it was $7...

Link to comment
Share on other sites

  • 2 weeks later...
Your fix was exactly what I was looking for!  Thanks for posting it.  Just wondering though, if you know of a quick fix for multiple multiplies?  I know the multiplier works when you just have one attribute value to multiply, but I'm trying to use to multiplier for dimensions and it only multiplies the last attribute value you select. 

 

If I select this for a product attribute (product is set to $1):

 

Height: 15 (*15)

Width: 7 (*7)

 

The product total will give me $7.  Although the subtotal gives me $105, correctly.  I proceeded toward the checkout to see which number will be used in the check out and it was $7...

 

Im trying to work out some algorythms right now, i am still having troubles when i attempt to add multiple items that each have different multipliers, it calculates 80% * $10 X 4 qty = $32 Correctly

 

but when you attempt to add a second item that has a 70% * $10 attribute it calculates $32 * .7 + $7 = $29.40 when in fact it should be $39

 

Help , does anyone know a fix, im going to try to work this out in the meantime

 

J

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...