Code:
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004 The zen-cart developers |
// | |
// | http://www.zen-cart.com/index.php |
// | |
// | Portions Copyright (c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | license AT zen-cart DOT com so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: default_filter.php 1223 2005-04-22 03:46:20Z ajeh $
//
// show the products of a specified STORE
if (isset($_GET['stores_id']) && $_GET['stores_id'] != '' )
{
if (isset($_GET['filter_id']) && zen_not_null($_GET['filter_id']))
{
// We are asked to show only a specific category
$listing_sql = "select " . $select_column_list . " p.products_id, stores_id, p.products_price, p.products_tax_class_id, pd.products_description, if(sp.status = '1', sp.specials_new_products_price, NULL) AS specials_new_products_price, IF(sp.status = '1', sp.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_STORES . " s left join " . TABLE_SPECIALS . " sp on p.products_id = sp.products_id where p.products_status = '1' and p.stores_id = s.stores_id and s.stores_id = '" . (int)$_GET['stores_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p2c.categories_id = '" . (int)$_GET['filter_id'] . "'";
} else {
// We show them all
$listing_sql = "select " . $select_column_list . " p.products_id, p.stores_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(sp.status = '1', sp.specials_new_products_price, NULL) as specials_new_products_price, IF(sp.status = '1', sp.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_STORES . " s left join " . TABLE_SPECIALS . " sp on p.products_id = sp.products_id where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p.stores_id = s.stores_id and s.stores_id = '" . (int)$_GET['stores_id'] . "'";
}
} else {
// show the products in a given categorie
if (isset($_GET['filter_id']) && zen_not_null($_GET['filter_id']))
{
// We are asked to show only specific catgeory
$listing_sql = "select " . $select_column_list . " p.products_id, p.stores_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(sp.status = '1', sp.specials_new_products_price, NULL) as specials_new_products_price, IF(sp.status = '1', sp.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_STORES . " s, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " sp on p.products_id = sp.products_id where p.products_status = '1' and p.stores_id = s.stores_id and s.stores_id = '" . (int)$_GET['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
} else {
// We show them all
$listing_sql = "select " . $select_column_list . " p.products_id, p.stores_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(sp.status = '1', sp.specials_new_products_price, NULL) as specials_new_products_price, IF(sp.status ='1', sp.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_STORES . " s on p.stores_id = s.stores_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " sp on p.products_id = sp.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
}
}
// set the default sort order setting from the Admin when not defined by customer
if (!isset($_GET['sort']) and PRODUCT_LISTING_DEFAULT_SORT_ORDER != '') {
$_GET['sort'] = PRODUCT_LISTING_DEFAULT_SORT_ORDER;
}
if ( (!isset($_GET['sort'])) || (!ereg('[1-8][ad]', $_GET['sort'])) || (substr($_GET['sort'], 0, 1) > sizeof($column_list)) )
{
for ($i=0, $n=sizeof($column_list); $i<$n; $i++)
{
if ($column_list[$i] == 'PRODUCT_LIST_NAME')
{
$_GET['sort'] = $i+1 . 'a';
$listing_sql .= " order by p.products_sort_order, pd.products_name";
break;
} else {
// sort by products_sort_order when PRODUCT_LISTING_DEFAULT_SORT_ORDER ia left blank
// for reverse, descending order use:
// $listing_sql .= " order by p.products_sort_order desc, pd.products_name";
$listing_sql .= " order by p.products_sort_order, pd.products_name";
break;
}
}
// if set to nothing use products_sort_order and PRODUCTS_LIST_NAME is off
if (PRODUCT_LISTING_DEFAULT_SORT_ORDER == '') {
$_GET['sort'] = '20a';
}
} else {
$sort_col = substr($_GET['sort'], 0 , 1);
$sort_order = substr($_GET['sort'], 1);
$listing_sql .= ' order by ';
switch ($column_list[$sort_col-1])
{
case 'PRODUCT_LIST_MODEL':
$listing_sql .= "p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;
case 'PRODUCT_LIST_NAME':
$listing_sql .= "pd.products_name " . ($sort_order == 'd' ? 'desc' : '');
break;
case 'PRODUCT_LIST_STORE':
$listing_sql .= "s.stores_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;
case 'PRODUCT_LIST_QUANTITY':
$listing_sql .= "p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;
case 'PRODUCT_LIST_IMAGE':
$listing_sql .= "pd.products_name";
break;
case 'PRODUCT_LIST_WEIGHT':
$listing_sql .= "p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;
case 'PRODUCT_LIST_PRICE':
// $listing_sql .= "final_price " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
$listing_sql .= "p.products_price_sorter " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;
}
}
// optional Product List Filter
if (PRODUCT_LIST_FILTER > 0)
{
if (isset($_GET['stores_id']) && $_GET['stores_id'] != '')
{
$filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id = cd.categories_id and cd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p.stores_id = '" . (int)$_GET['stores_id'] . "' order by cd.categories_name";
} else {
$filterlist_sql= "select distinct s.stores_id as id, s.stores_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_STORES . " s where p.products_status = '1' and p.stores_id = s.stores_id and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by s.stores_name";
}
$filterlist = $db->Execute($filterlist_sql);
if ($filterlist->RecordCount() > 1)
{
$do_filter_list = true;
if (isset($_GET['stores_id']))
{
$getoption_set = true;
$get_option_variable = 'stores_id';
$options = array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES));
} else {
$options = array(array('id' => '', 'text' => TEXT_ALL_STORES));
}
while (!$filterlist->EOF) {
$options[] = array('id' => $filterlist->fields['id'], 'text' => $filterlist->fields['name']);
$filterlist->MoveNext();
}
}
}
// Get the right image for the top-right
$image = DIR_WS_TEMPLATE_IMAGES . 'table_background_list.gif';
if (isset($_GET['stores_id']))
{
$sql = "select stores_image
from " . TABLE_STORES . "
where stores_id = '" . (int)$_GET['stores_id'] . "'";
$image_name = $db->Execute($sql);
$image = $image_name->fields['stores_image'];
} elseif ($current_category_id) {
$sql = "select categories_image from " . TABLE_CATEGORIES . "
where categories_id = '" . (int)$current_category_id . "'";
$image_name = $db->Execute($sql);
$image = $image_name->fields['categories_image'];
}
?>
This is how it looks like in tpl_stores_select.php:
Code:
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers |
// | |
// | http://www.zen-cart.com/index.php |
// | |
// | Portions Copyright (c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | license AT zen-cart DOT com so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: tpl_stores_select.php 1266 2005-07-27 02:51:24Z xxxx$
//
$content = '<center>';
$content.= zen_draw_form('stores', zen_href_link(FILENAME_DEFAULT, '', 'NONSSL', false), 'get');
$content .= zen_draw_pull_down_menu('stores_id', $store_sidebox_array, (isset($_GET['stores_id']) ? $_GET['stores_id'] : ''), 'onchange="this.form.submit();" class="DropdownMeny" size="' . MAX_STORES_LIST . '"') . zen_hide_session_id() . zen_draw_hidden_field('typefilter', 'stores');
$content .= zen_draw_hidden_field('main_page', FILENAME_DEFAULT) . '</center></form>';
?>
I've put a value 'stores_id' in table 'get_terms_to_filter'...
Bookmarks