Community Add-Ons

Maintainers: athyholdt
Add file to this package
Top » Features

Go directly to product when category has only one product
for osCommerce Online Merchant v2.2

This mod will take you directly to product info when the clicked category only has one product.

Its simple to implement, only one file to change.

Legend:  Download   Report
Expand All / Collapse All
Go directly to product when category has only one product - v1.1 Phalen 24 Aug 2006  

i noticed that when i hav sub-categories - this contrib did not go directly to the product (category has one product).

messed around with the code a bit... probably not the cleanest code in the world - but it works - tested it - looks fine

just use this code instead....

$o_cPath = $cPath;

if(strstr($cPath, '_')) {
$tmp = explode('_', $cPath);
$cPathTmp = $tmp[(sizeof($tmp) - 1)];
} else {
$cPathTmp = $cPath;
}

if (tep_count_products_in_category($cPathTmp) == 1) {
$oneprodquery = tep_db_query("select DISTINCTROW p.products_id from " . TABLE_PRODUCTS . " p, " .

TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and

p2c.categories_id = '" . (int)$current_category_id . "'");
$oneprod = tep_db_fetch_array($oneprodquery);

tep_redirect(FILENAME_PRODUCT_INFO . "?cPath=" . $o_cPath . "&products_id=" . $oneprod['products_id'] .

"&osCsid=" . tep_session_id());
}

Go directly to product when category has only one product athyholdt 18 Aug 2006