Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How do I get my option values ordered?


marcgaston

Recommended Posts

I have more or less numerical option values (5 mm, 10 mm, 15 mm, ...). They show up all mixed up on the product page which will probably confuse my customers.

Is there a trick on how to overcome this problem?

I prefer a hacking solution to the database using phpmyadmin over a contribution (sorting algorithms etc.) to keep the numbers of contributions and alterations to the shop as small as necessary.

 

Thanks

 

Marc

Link to comment
Share on other sites

  • 3 weeks later...

Hi Maggie,

 

open catalog/product_info.php

and look for

 

$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 = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");

 

underneath it replace the original code

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

         $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);

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

           $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';

         }

       }

 

with this:

 

        $products_options_array_temp = array();

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

         $products_options_array_temp[$products_options['products_options_values_id']] = $products_options['products_options_values_name'];

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

           $products_options_array_temp[$products_options['products_options_values_id']] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';

         }

       }

       asort ($products_options_array_temp, SORT_STRING);

       reset ($products_options_array_temp);

       while (list ($arr_key, $arr_val) = each ($products_options_array_temp)) {

         $products_options_array[] = array('id' => $arr_key, 'text' => $arr_val);

       }

 

Good luck

 

Marc

Link to comment
Share on other sites

I'm not sure if I read your whole post last time. If you want to order by one of the existing fields in the database, you could add an order by clause to the db query. If none of the existing fields fits what you need, you could add an extra column (products_attributes_sort_order) with an order by clause. You would add and modify the column in phpMyAdmin. This is part of what the Attributes Sorter does, minus the copier and admin interface.

 

Cheers,

Matt

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...