Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Option Type Feature v1.4 (for osc 2.2 ms1)


Guest

Recommended Posts

Hi Barry,

 

I visited your site and tried to add a frame to my purchase. It did not add the additional cost of the frame.

 

I am using Netscape Navigator 7.0 running on Microsoft .net.

 

Check it out

 

Byron :shock:

BG

 

Making the internet community better. Knowledge is power.

Link to comment
Share on other sites

  • Replies 192
  • Created
  • Last Reply

Top Posters In This Topic

Ok Barry,

 

Let me say I choose a picture for L9.99. Then I choose a frame for L2.95. The total cost of the Picture & frame should be L12.94.

 

Well when I get to the page to Log in I am still seeing the price of L9.99. It has not yet included the cost of the frame. Or is that I would have to log in first.

 

Byron :shock:

BG

 

Making the internet community better. Knowledge is power.

Link to comment
Share on other sites

I am equally confused as i still don't know what you are talking about. What products are you trying to add to the cart?

 

Plus pm me as this is a little off topic for this thread.

 

cheers

barry

Link to comment
Share on other sites

Install/merge Conte's mod

 

Add "input"-option in admin/includes/languages/*/product_attibutes.php. After line 39 should look like this

 

$products_attributes_type = array('Disabled',

                               'Select',

                               'Checkbox',

                               'Radio',

                               'Select Multiple',

                               'Text',

                               'Input'

);

?>

 

These are my changes in conte's catalog/product_info.php

 

1. About Line 65

 

//OTF Begin

   $products_attributes = tep_db_query("select popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "' and patrib.options_type_id > 0");

   if (tep_db_num_rows($products_attributes)) {

     $products_attributes = '1';

   } else {

     $products_attributes = '0';

   }

//OTF End

 

 

About Line 114 change the lines between <?php and case '1' : // select

 

//OTF Begin

   if ($products_attributes == '1') {

     $products_options_name = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_type, popt.products_options_length, popt.products_options_comment, patrib.options_type_id from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "' and patrib.options_type_id > 0 group by popt.products_options_name order by patrib.attribute_order, patrib.options_type_id, popt.products_options_name, popt.products_options_id");

     echo '<b>' . TEXT_PRODUCT_OPTIONS . '</b><br>';

     echo '<table border="0" cellpading="0" cellspacing"0">';

     while ($products_options_name_values = tep_db_fetch_array($products_options_name)) {

      switch ($products_options_name_values['options_type_id']) {

//OTF End

 

Add this in line 251 after the "break;" of case 5:

 

  case '6' :  // input

       $selected = 1;

       $products_options = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.collegamento from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . $products_options_name_values['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "' and pa.options_type_id = 6 order by pa.attribute_order");

       

 while ($products_options_values = tep_db_fetch_array($products_options)) {

         $linked_attrib = tep_linked_attributes($products_options_values['collegamento'],$HTTP_GET_VARS['products_id']);

   echo '<tr><td class="main">' . $products_options_name_values['products_options_name'] . ': </td><td class="main"><input type="text" name ="id[' . TEXT_PREFIX .$products_options_name_values['products_options_id'] . ']" size="' . $products_options_name_values['products_options_length'] .'" maxlength="' . $products_options_name_values['products_options_length'] . '" value="' . $cart->contents[$HTTP_GET_VARS['products_id']]['attributes_values'][$products_options_name_values['products_options_id']] .'">  ' . $products_options_name_values['products_options_comment']; $products_options_values['products_options_values_id'] . $linked_attrib;

         if (strchr($products_options_values['price_prefix'],'s')) {

           $special_class = 'productSpecialPrice';

         } else {

           $special_class = 'main';

         }

         echo '<tr><td class="' . $special_class . '">  ';

         if (($products_options_values['options_values_price'] != '0') && (!strchr($products_options_values['price_prefix'],'i'))) {

           echo ' (' . tep_prefix_view($products_options_values['price_prefix']) . ' '. $currencies->display_price($products_options_values['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';

         }

         echo '</td><td>' . tep_draw_hidden_field($name_text) . '</td></tr>' . "n";

        }

       }

 

But I have a problem in the shopping cart, because the text is not displayd.

Link to comment
Share on other sites

In my opinion it is more difficult to add the text option to conte's mod. I have the radio,select & text working properly with chandras mod. The checkboxes will only display one per option value however if you set up more than one checkbox value you can have multilpe checkboxes and they all add info to the cart.

 

cheers

barry

Link to comment
Share on other sites

Hi!!!

 

I've installed everything per the directions....*i think*...but for some reason...the text does not show up at all in the shopping cart or in the admin section...:( I checked the mods and everything.....could it be the database?!?!?

 

 

Please help....

Link to comment
Share on other sites

I have been busy lately but with the option type feature by ConteZero

 

found the problem in versions 2.02 test not displaying in in product info.

 

in product_info.php

 

on the line that has tep_draw_hidden_field change that to

 

tep_draw_hidden_field($name_text, $value_text)

change to:

tep_draw_textarea_field($name_text, $value_text, 30, 6)

 

the two number that were added are for width of 30, and 6 lines height.

 

example:

 

case '5' : // text

$products_options = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.collegamento from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . $products_options_name_values['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "' and pa.options_type_id = 5 order by pa.attribute_order");

echo '<tr><td class="main"><br><b>' . $products_options_name_values['products_options_name'] . ':</b></td><td> </td></tr>' . "n";

while ($products_options_values = tep_db_fetch_array($products_options)) {

$linked_attrib = tep_linked_attributes($products_options_values['collegamento'],$HTTP_GET_VARS['products_id']);

$name_text = 'id[]';

$value_text = '{' . $products_options_name_values['products_options_id'] . '}' . $products_options_values['products_options_values_id'] . $linked_attrib;

if (strchr($products_options_values['price_prefix'],'s')) {

$special_class = 'productSpecialPrice';

} else {

$special_class = 'main';

}

echo '<tr><td class="' . $special_class . '">  ' . $products_options_values['products_options_values_name'];

if (($products_options_values['options_values_price'] != '0') && (!strchr($products_options_values['price_prefix'],'i'))) {

echo ' (' . tep_prefix_view($products_options_values['price_prefix']) . ' '. $currencies->display_price($products_options_values['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';

}

echo '</td><td>' . tep_draw_hidden_field($name_text, $value_text) . '</td></tr>' . "n";

}

break;

}

 

}

echo '</table>';

}

?>

 

Should look like:

 

case '5' : // text

$products_options = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.collegamento from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . $products_options_name_values['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "' and pa.options_type_id = 5 order by pa.attribute_order");

echo '<tr><td class="main"><br><b>' . $products_options_name_values['products_options_name'] . ':</b></td><td> </td></tr>' . "n";

while ($products_options_values = tep_db_fetch_array($products_options)) {

$linked_attrib = tep_linked_attributes($products_options_values['collegamento'],$HTTP_GET_VARS['products_id']);

$name_text = 'id[]';

$value_text = '{' . $products_options_name_values['products_options_id'] . '}' . $products_options_values['products_options_values_id'] . $linked_attrib;

if (strchr($products_options_values['price_prefix'],'s')) {

$special_class = 'productSpecialPrice';

} else {

$special_class = 'main';

}

echo '<tr><td class="' . $special_class . '">  ' . $products_options_values['products_options_values_name'];

if (($products_options_values['options_values_price'] != '0') && (!strchr($products_options_values['price_prefix'],'i'))) {

echo ' (' . tep_prefix_view($products_options_values['price_prefix']) . ' '. $currencies->display_price($products_options_values['options_values_price'], tep_get_tax_rate($product_info_values['products_tax_class_id'])) .') ';

}

echo '</td><td>' . tep_draw_textarea_field($name_text, $value_text, 30, 6) . '</td></tr>' . "n"; //this is the line that's changed

}

break;

}

Link to comment
Share on other sites

I have been busy lately but with the option type feature by ConteZero  

 

found the problem in versions 2.02 test not displaying in in product info.

 

in product_info.php

 

on the line that has tep_draw_hidden_field change that to

 

tep_draw_hidden_field($name_text, $value_text)

change to:

tep_draw_textarea_field($name_text, $value_text, 30, 6)

 

the two number that were added are for width of 30, and 6 lines height.

 

example:

 

case '5' :  // text  

       $products_options = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.collegamento from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . $products_options_name_values['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "' and pa.options_type_id = 5 order by pa.attribute_order");

       echo '<tr><td class="main"><br><b>' . $products_options_name_values['products_options_name'] . ':</b></td><td> </td></tr>' . "n";

       while ($products_options_values = tep_db_fetch_array($products_options)) {

         $linked_attrib = tep_linked_attributes($products_options_values['collegamento'],$HTTP_GET_VARS['products_id']);

         $name_text = 'id[]';

         $value_text = '{' . $products_options_name_values['products_options_id'] . '}' . $products_options_values['products_options_values_id'] . $linked_attrib;

         if (strchr($products_options_values['price_prefix'],'s')) {

           $special_class = 'productSpecialPrice';

         } else {

           $special_class = 'main';

         }

         echo '<tr><td class="' . $special_class . '">  ' . $products_options_values['products_options_values_name'];

         if (($products_options_values['options_values_price'] != '0') && (!strchr($products_options_values['price_prefix'],'i'))) {

           echo ' (' . tep_prefix_view($products_options_values['price_prefix']) . ' '. $currencies->display_price($products_options_values['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';

         }

         echo '</td><td>' . tep_draw_hidden_field($name_text, $value_text) . '</td></tr>' . "n";  

       }

       break;

      }

 

     }

     echo '</table>';

   }

?>

 

Should look like:

 

case '5' :  // text

          $products_options = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.collegamento from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . $products_options_name_values['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "' and pa.options_type_id = 5 order by pa.attribute_order");

          echo '<tr><td class="main"><br><b>' . $products_options_name_values['products_options_name'] . ':</b></td><td> </td></tr>' . "n";

          while ($products_options_values = tep_db_fetch_array($products_options)) {

            $linked_attrib = tep_linked_attributes($products_options_values['collegamento'],$HTTP_GET_VARS['products_id']);

            $name_text = 'id[]';

            $value_text = '{' . $products_options_name_values['products_options_id'] . '}' . $products_options_values['products_options_values_id'] . $linked_attrib;

            if (strchr($products_options_values['price_prefix'],'s')) {

              $special_class = 'productSpecialPrice';

            } else {

              $special_class = 'main';

            }

            echo '<tr><td class="' . $special_class . '">  ' . $products_options_values['products_options_values_name'];

            if (($products_options_values['options_values_price'] != '0') && (!strchr($products_options_values['price_prefix'],'i'))) {

              echo ' (' . tep_prefix_view($products_options_values['price_prefix']) . ' '. $currencies->display_price($products_options_values['options_values_price'], tep_get_tax_rate($product_info_values['products_tax_class_id'])) .') ';

            }

            echo '</td><td>' . tep_draw_textarea_field($name_text, $value_text, 30, 6) . '</td></tr>' . "n"; //this is the line that's changed

          }

          break;

         }

 

All very well but how do you get the text entered to pass into the shopping cart and get stored with the customers info?

 

cheers

barry

Link to comment
Share on other sites

Well Ive been busy, down to just 12 more ad's for this month, I supplied just one piece of the puzzle when I posted the above.. Hopefully I will get more time to work on it this week end.

Link to comment
Share on other sites

you must have missed a couple of variable name changes, as that is what would stop the info getting passed through the shopping cart/checkout process.

 

looking for variables option / option_id and value_value_id. I think that is the ones.

 

cheers

barry

Link to comment
Share on other sites

okay...i finally got the type to display in the shopping cart...but when i try to check out...i get this error

 

Parse error: parse error, unexpected $ in /home/virtual/site26/fst/var/www/html/checkout_process.php on line 307

 

i think it has to do with this...

 

// dogu 2003-28-12 update insert query. changing to use values form $order->products.

$sql_data_array = array('orders_id' => $insert_id,

'orders_products_id' => $order_products_id,

'products_options' => $attributes_values['products_options_name'],

'products_options_values' => $order->products[$i]['attributes'][$j]['value'],

'options_values_price' => $attributes_values['options_values_price'],

'price_prefix' => $attributes_values['price_prefix']);

 

//* $sql_data_array = array('orders_id' => $insert_id,

// 'orders_products_id' => $order_products_id,

//'products_options' => $attributes_values['products_options_name'],

//'products_options_values' => $attributes_values['products_options_values_name'],

//'options_values_price' => $attributes_values['options_values_price'],

//'price_prefix' => $attributes_values['price_prefix']);

tep_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);

 

if ((DOWNLOAD_ENABLED == 'true') && isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) {

$sql_data_array = array('orders_id' => $insert_id,

'orders_products_id' => $order_products_id,

'orders_products_filename' => $attributes_values['products_attributes_filename'],

'download_maxdays' => $attributes_values['products_attributes_maxdays'],

'download_count' => $attributes_values['products_attributes_maxcount']);

tep_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);

}

//dogu 2003-02-28 changing to use values form $order->products.

//CLR 2003-03-12 add call to tep_decode_specialchars()

$products_ordered_attributes .= "nt" . $attributes_values['products_options_name'] . ' ' . tep_decode_specialchars($order->products[$i]['attributes'][$j]['value']);

// $products_ordered_attributes .= "nt" . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name'];

}

}

//------insert customer choosen option eof ----

$total_weight += ($order->products[$i]['qty'] * $order->products[$i]['weight']);

$total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];

$total_cost += $total_products_price;

 

$products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "n";

}

 

can anyone see something wrong?

Link to comment
Share on other sites

okay...so i've been messing with it...and i get this:

 

 

Parse error: parse error, unexpected $ in /home/virtual/site26/fst/var/www/html/checkout_process.php on line 307

But this is the last line of checkout_process.php and there's no blanks or anything it reads: ?>

 

when i have THIS:

 

 

// dogu 2003-28-12 update insert query. changing to use values form $order->products.

$sql_data_array = array('orders_id' => $insert_id,

'orders_products_id' => $order_products_id,

'products_options' => $attributes_values['products_options_name'],

'products_options_values' => $order->products[$i]['attributes'][$j]['value'],

'options_values_price' => $attributes_values['options_values_price'],

'price_prefix' => $attributes_values['price_prefix']);

 

/* $sql_data_array = array('orders_id' => $insert_id,

'orders_products_id' => $order_products_id,

'products_options' => $attributes_values['products_options_name'],

'products_options_values' => $attributes_values['products_options_values_name'],

'options_values_price' => $attributes_values['options_values_price'],

'price_prefix' => $attributes_values['price_prefix']);

*/

Link to comment
Share on other sites

I missing $ ... bracket ... ?> ... semi-colon etc. can result in silly things like error on line 307 when the error is really on line 102 ... :shock:

 

Ain't php fun? 8)

Link to comment
Share on other sites

anyone know if you are supposed to be able to add a price to the TEXT options?

 

For some reason, I can add the price, but the price doesnt show up in the shopping cart....

 

any ideas?

Link to comment
Share on other sites

Ok folks. First of all thanks to everybody who has been working so hard to get the checkboxes working properly.

 

I ran the code by teksigns earlier and it worked for him as well, so here it is. I have put a comment tag after the 3 lines I adjusted for easy reference.

 

case ($products_options_name['products_options_type'] == PRODUCTS_OPTIONS_TYPE_CHECKBOX): 

                 //CLR 2003-03-18 Add logic for checkboxes 

                 echo '<tr><td class="main" valign="top">' . $products_options_name['products_options_name'] . ': </td><td class="main">'; 

                 $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'"); 

                 $checkbox_counter = 1; // added by ECS

     while ($products_options_array = tep_db_fetch_array($products_options_query)) {  

  	 echo tep_draw_checkbox_field('id[' . $products_options_name['products_options_id'] . '_' . $checkbox_counter . ']', $products_options_array['products_options_values_id']); // modified by ECS 

                   echo $products_options_array['products_options_values_name']; 

                   echo $products_options_name['products_options_comment'] . ' '; 

                   if ($products_options_array['options_values_price'] != '0') { 

                     echo '(' . $products_options_array['price_prefix'] . $currencies->display_price($products_options_array['options_values_price'], $product_info_values['products_tax_class_id']) .')<br />'; 

                   } else {

        echo '<br />';

      }

     $checkbox_counter++; //added by ECS  

                 } 

                 echo '</td></tr>'; 



                 break;

 

 

 

Basically, the problem was that each of the checkboxes had the same name. If more than one box was checked it would not show up in the shopping cart because the while loop was over-writing the value of the previous checkbox each time around. What I did was create a checkbox counter that would be appended to the name and that prevents it from being overwritten. Hence they all show up properly in the shopping cart. Please try out the code and let me know if you encounter any problems.

 

Eric

Link to comment
Share on other sites

yep that little addition to the code works brill :D

 

i had played with something like that for a couple of hours but for some reason couldn't get it to work and was driving me mad.

 

a little question though could the single select logic be modified to allow multiple selects?

 

cheers

barry

Link to comment
Share on other sites

There is one issue I have come across with this update through my further testing.

 

If a person adds an item to their cart when they are not logged in (or have not setup an account yet) it works fine until they get to the checkout page via the login page. There is something in the login page code that causes the multiple checkbox attributes to not be entered into the customers_basket_attributes table correctly.

 

It is interesting that everything works just fine if the person logs in first and then starts adding items to the cart and then goes to check out.

 

I am hoping that somebody who is familiar with the inner workings of the login/checkout combination could shine some light on this situation.

 

Please let me know if anybody can give some insights.

 

Eric

Link to comment
Share on other sites

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...