845-820-0262
Middletown, NY
info@eclectictech.net

September 15, 2006

oscommerce drop-down selection box hack

Filed under: Technology, Programming, Information — Crisses @ 3:52 pm

I was having a heck of a time today dealing with drop-down product option selections in oscommerce. I wrote a hack to catalog/includes/functions/html_output.php in the function definition for tep_draw_pull_down_menu I changed the following text:


    for ($i=0, $n=sizeof($values); $i<$n; $i++) {
      $field .= '‘;
    }

To the following:

	// Criss - XES - altered the following:

	foreach ($values as $i=>$value) {
			$xes_values[$value['id']] = $value['text'];	}
	asort($xes_values);

	    foreach ($xes_values as $xes_id=>$xes_text) {
      $field .= '‘;
    }

Now when I can have product option “A - 9oz” and “B - 30oz” and count on option A being the default selected item if the customer doesn’t change the option. Try as I might “B - 20oz” was the option selected. Whether I re-added the options in a different order, whether I took out A B C D, etc. If it were sorted in reverse order, I could have left out A B C D, because 9oz should sort to the top of the list. This wasn’t the issue. I have no idea why the program was so stubborn about sort order, but now all drop-downs, like it or not, throughout the site, will be sorted alphabetically!

I hope people find this code snippet helpful!

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Web creation, hosting & design
by Eclectic Tech, LLC