Jump to content


Corporate Sponsors


Latest News: (loading..)

* * * * * 1 votes

Tip: Radio buttons for Product Options


31 replies to this topic

#21 slimim

  • Community Member
  • 28 posts
  • Real Name:Imran

Posted 15 April 2006, 10:57

I'm having no luck I get the following error Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/cubeappl/public_html/includes/functions/html_output.php on line 37

I checked this line:
$field .= '></p></td><td><p class="main">' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</p></td></tr>';

and it is fine am I doing something wrong?

#22 Qihun

  • Community Member
  • 561 posts
  • Real Name:miclosh
  • Location:planet Earth

Posted 15 April 2006, 11:09

$field .= '></p></td><td><p class="main">' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => '& # 0 3 9; ', '<' => '<', '>' => '>')) . '</p></td></tr>';

& # 0 3 9 ; without whitespace

#23 slimim

  • Community Member
  • 28 posts
  • Real Name:Imran

Posted 15 April 2006, 12:29

View PostQihun, on Apr 15 2006, 12:09 PM, said:

$field .= '></p></td><td><p class="main">' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => '& # 0 3 9; ', '<' => '<', '>' => '>')) . '</p></td></tr>';

& # 0 3 9 ; without whitespace

Thank you so much Qihun, It worked, and also thanks to Moufasa2 and others

#24 bored

  • Community Member
  • 18 posts
  • Real Name:Kevin

Posted 12 July 2006, 17:12

this mod works great, but all the options are pre selected with the LAST button, how can I get this to be set so the FIRST radio button is selected and not the last?

#25 zerodash

  • Community Member
  • 121 posts
  • Real Name:Gregg

Posted 18 July 2006, 14:30

View Postbored, on Jul 12 2006, 01:12 PM, said:

this mod works great, but all the options are pre selected with the LAST button, how can I get this to be set so the FIRST radio button is selected and not the last?

I've been trying to figure this out as well. Anyone have any ideas?

#26 zerodash

  • Community Member
  • 121 posts
  • Real Name:Gregg

Posted 18 July 2006, 19:05

GOT IT! :D

Just use a conditional loop to only mark the first attribute as "checked":

function tep_radiobutton_menu($name, $values, $default = '', $parameters = '', $required = false) {
$field = '<table border="0" cellpadding="2" cellspacing="0"><label name="' . tep_output_string($name) . '"';

if (tep_not_null($parameters)) $field .= ' ' . $parameters;

$field .= '>';

if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]);


for ($i=0, $n=sizeof($values); $i<$n; $i++) {

if ($i==0)
$field .= '<tr><td><p class="main"><input checked type="radio" name="' . tep_output_string($name) . '" value="' . tep_output_string($values[$i]['id']) . '" ';
else
$field .= '<tr><td><p class="main"><input  type="radio" name="' . tep_output_string($name) . '" value="' . tep_output_string($values[$i]['id']) . '"'; 

if ($default == $values[$i]['id']) {
$field .= ' ';
}

$field .= '></p></td><td><p class="main">' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => '& # 0 3 9; ', '<' => '<', '>' => '>')) . '</p></td></tr>';
}
$field .= '</label></table>';

if ($required == true) $field .= TEXT_FIELD_REQUIRED;

return $field;
}


#27 solucionesmipc

  • Community Member
  • 7 posts
  • Real Name:diego

Posted 02 August 2006, 14:01

is there any way to do this?

product name , description, etc.

size quantity

s blank space to input the quantity required
m blank space to input the quantity required
l blank space to input the quantity required
xl blank space to input the quantity required


add tocart button

when i click in add to cart button , i need the program sumarize every quantity selected in every size option.

thanks a lot , i would appreciate your help.


Diego Fernando Ruales

#28 concorde44

  • Community Member
  • 75 posts
  • Real Name:Seb
  • Location:Nantes, FRANCE

Posted 02 August 2006, 21:24

View Postsolucionesmipc, on Aug 2 2006, 03:01 PM, said:

is there any way to do this?

product name , description, etc.

size quantity

s blank space to input the quantity required
m blank space to input the quantity required
l blank space to input the quantity required
xl blank space to input the quantity required
add tocart button

when i click in add to cart button , i need the program sumarize every quantity selected in every size option.

thanks a lot , i would appreciate your help.
Diego Fernando Ruales

Yeah, me too !
If no answer else, I tried and you should try too, this contrib :
http://www.oscommerce.com/community/contributions,3345/
this will break the drop down menu options into a table with at the end of each attribute line, the ability to enter the qty needed for each attribute. then for me the "add to cart" button don't add anything to the cart ! ? That's why I was surfing the forums to find an answer or a support thread and I found this post with your need....
Seb
Osc 2.2 MS2

#29 deuce135

  • Community Member
  • 26 posts
  • Real Name:John

Posted 03 October 2006, 18:41

i need some help, i need to get this easypopulate working but i get the following error:Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in C:\Inetpub\vhosts\direcconnect.org\httpdocs\oscommerce\admin\includes\boxes\catalog.php on line 29

here is the code:

<?php
/*
$Id: catalog.php,v 1.1.1.1 2005/09/09 07:27:08 yguskov Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright © 2002 osCommerce

Released under the GNU General Public License
*/
?>
<!-- catalog //-->
<tr>
<td>
<?php
$heading = array();
$contents = array();

$heading[] = array('text' => BOX_HEADING_CATALOG,
'link' => tep_href_link(FILENAME_CATEGORIES, 'selected_box=catalog'));

if ($selected_box == 'catalog') {
$contents[] = array('text' => '<a href="' . tep_href_link(FILENAME_CATEGORIES, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_CATEGORIES_PRODUCTS . '</a><br>' .
'<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_CATEGORIES_PRODUCTS_ATTRIBUTES . '</a><br>' .

'<a href="' . tep_href_link('easypopulate.php', '', 'NONSSL') . '" class="menuBoxContentLink">Easy Populate</a><br>' [Line 29]

'<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '', 'NONSSL') . '"
class="menuBoxContentLink">' . BOX_CATALOG_CATEGORIES_PRODUCTS_ATTRIBUTES .
'</a><br>' .z
'<a href="' . tep_href_link(FILENAME_MANUFACTURERS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_MANUFACTURERS . '</a><br>' .
'<a href="' . tep_href_link(FILENAME_REVIEWS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_REVIEWS . '</a><br>' .
'<a href="' . tep_href_link(FILENAME_SPECIALS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_SPECIALS . '</a><br>' .
'<a href="' . tep_href_link(FILENAME_PRODUCTS_EXPECTED, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_PRODUCTS_EXPECTED . '</a>');
}

$box = new box;
echo $box->menuBox($heading, $contents);
?>
</td>
</tr>
<!-- catalog_eof //-->

Edited by deuce135, 03 October 2006, 18:43.


#30 ansa

  • Community Member
  • 41 posts
  • Real Name:Andrew
  • Location:Ontario, Canada

Posted 16 October 2006, 17:33

View Postconcorde44, on Aug 2 2006, 05:24 PM, said:

Yeah, me too !
If no answer else, I tried and you should try too, this contrib :
http://www.oscommerce.com/community/contributions,3345/
this will break the drop down menu options into a table with at the end of each attribute line, the ability to enter the qty needed for each attribute. then for me the "add to cart" button don't add anything to the cart ! ? That's why I was surfing the forums to find an answer or a support thread and I found this post with your need....
Seb


There is a mistake in the function - it should be :

function tep_draw_radio_menu($name, $values, $default = '', $parameters = '', $required = false)
{
$field = '<label>';
if (tep_not_null($parameters)) $field .= ' ' . $parameters;
if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]);

for ($i=0, $n=sizeof($values); $i<$n; $i++) {
$field .= '<input type="radio" value="' . tep_output_string($values[$i]['id']) . '"';
$field .= ' name="' . tep_output_string($name) . '"';
if (tep_not_null($parameters)) $field .= ' ' . $parameters;

if ($default == $values[$i]['id']) {
$field .= 'SELECTED';
}
$field .= '>' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => '', '<' => '<', '>' => '>')) . '<br>';
}
$field .= '</label>';
if ($required == true) $field .= TEXT_FIELD_REQUIRED;
return $field;
}

Works fine!

#31 bigbird9944

  • Community Member
  • 3 posts
  • Real Name:Philip Percival

Posted 11 November 2006, 12:28

I love the simplicity of this option compared to the other contributions. Would anyone know how to make all the buttons selectable? Or is this too complicated a bit of programming. Forgive my ignorance in these matters. Thanks

#32 stasmmr

  • Community Member
  • 29 posts
  • Real Name:terri
  • Location:margaret river WA

Posted 28 February 2007, 22:36

View PostQihun, on Apr 15 2006, 12:46 PM, said:

you have parse error because posting form on this forum replace tags with simbols
in this line
$field .= '></p></td><td><p class="main">' . tep_output_string($values[$i]['text'], array('"' => '&quot;', '\'' => ''', '<' => '&lt;', '>' => '&gt;')) . '</p></td></tr>';
this is function in catalog/includes/html_output.php

taken from last post of Moufasa2 ( thank you very much , great help to me )

function tep_radiobutton_menu($name, $values, $default = '', $parameters = '', $required = false) {
$field = '<table border="0" cellpadding="2" cellspacing="0"><label name="' . tep_output_string($name) . '"';

if (tep_not_null($parameters)) $field .= ' ' . $parameters;

$field .= '>';

if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]);

for ($i=0, $n=sizeof($values); $i<$n; $i++) {
$field .= '<tr><td><p class="main"><input checked type="radio" name="' . tep_output_string($name) . '" value="' . tep_output_string($values[$i]['id']) . '"';
if ($default == $values[$i]['id']) {
$field .= ' ';
}

$field .= '></p></td><td><p class="main">' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</p></td></tr>';
}
$field .= '</label></table>';

if ($required == true) $field .= TEXT_FIELD_REQUIRED;

return $field;
}

it called tep_radiobutton_menu , so , you need to modify catalog/product_info.php

find there
<td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td>

and replace with
<td  align="CENTER" class="main"><?php echo tep_radiobutton_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td>

thats all , now instead of pull_down menu you have options listed with radio_buttons next to them

Hi
I have tried this cont many times and i keeep getting this parse error.
$field .= '></p></td><td><p class="main">' . tep_output_string($values[$i]['text'], array('"' => '&quot;', '\'' => ''', '<' => '&lt;', '>' => '&gt;')) . '</p></td></tr>';
I have tried cut and paste, i have typed in mysed and still get parse error on this line.
I have found that it has to do with this snippet '<' => '&lt;',. Do you have any tips as to resolve this?
Desperately need radio buttons for site too many different options on products .

Regards
stasmmr