Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to: Quantity box, Sorting Dropdown box...


popeye

Recommended Posts

When I list products from given category, I want to add "quantity box" to each product row, by which customers can enter the number of product they want to buy ( like the one u see after u click to "buy now" button or in shopping cart content ).

 

And I also want to insert a "Sorting Dropdown box" above product listing. Because some customer find it is very difficult for sorting products if they don't click to "Product Name+" or "Price+" ...

in my case, i have to put some text like this " Please click to the labels in product listing to sort products by these options".

 

Thanks.

Link to comment
Share on other sites

Quantity Box

 

$sort_array = array();
$sort_array[] = array('id' => '2a', 'text' => 'Product Name Ascending');
$sort_array[] = array('id' => '2d', 'text' => 'Product Name Descending');
$sort_array[] = array('id' => '3a', 'text' => 'Product Price Ascending');
$sort_array[] = array('id' => '3d', 'text' => 'Product Price Descending');

echo tep_draw_form('sort_order', tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('sort')), 'get') . tep_draw_pull_down_menu('sort', $sort_array, (isset($HTTP_GET_VARS['sort']) ? $HTTP_GET_VARS['sort'] : ''), 'onChange="this.form.submit();"') . '</form>';

Note: numbers are based on column order in the product listing. Adjust as needed for your store.

 

Hth,

Matt

Link to comment
Share on other sites

Better way to do this based on existing code. In index.php around lines 251-6, change

        echo tep_draw_hidden_field('sort', $HTTP_GET_VARS['sort']);
       while ($filterlist = tep_db_fetch_array($filterlist_query)) {
         $options[] = array('id' => $filterlist['id'], 'text' => $filterlist['name']);
       }
       echo tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()"');
       echo '</form></td>' . "\n";

to

        echo tep_draw_hidden_field('sort', $HTTP_GET_VARS['sort']);
       while ($filterlist = tep_db_fetch_array($filterlist_query)) {
         $options[] = array('id' => $filterlist['id'], 'text' => $filterlist['name']);
       }
       echo tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()"') . '<br>';
       $sort_array = array();
       $sort_array[] = array('id' => '2a', 'text' => 'Product Name Ascending');
       $sort_array[] = array('id' => '2d', 'text' => 'Product Name Descending');
       $sort_array[] = array('id' => '3a', 'text' => 'Product Price Ascending');
       $sort_array[] = array('id' => '3d', 'text' => 'Product Price Descending');
       echo tep_draw_pull_down_menu('sort', $sort_array, (isset($HTTP_GET_VARS['sort']) ? $HTTP_GET_VARS['sort'] : ''), 'onChange="this.form.submit();"');
       echo '</form></td>' . "\n";

Note: that in the ids, the digit is the column number (set in admin > Configuration > Product Listing) and the a/d stands for ascending or descending. Change to match your store settings.

 

Hth,

Matt

Link to comment
Share on other sites

  • 6 months later...

and what to do if you have two languages, do i need to edit or place this code somewhere else with the translation too or is this impossible, since the modification is done on the main "index.php" page ??

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...