Community Add-Ons

Maintainers: hari_shyam
Add file to this package
Top » Features

Only product in category : Product list to product information page
for osCommerce Online Merchant v2.2

Hi..

This is my first contribution. Starting out with a simple one.

I frequently get clients asking for this feature. so i thought it would save time and money for the client ( any sop owner ) looking for a fix.

This change to the index.php makes sure that the customer/user is redirected to the products information page in case there is only one product in the particular category.

=======================================
1. find the line:
if (isset($cPath) && tep_not_null($cPath)) {
$categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
$cateqories_products = tep_db_fetch_array($categories_products_query);
if ($cateqories_products['total'] > 0) {

Add in the following code below the above code snippet.

if ($cateqories_products['total'] == 1)
{
$query = tep_db_query("select p2c.products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where categories_id = '" . (int)$current_category_id . "'");
$prods_arr = tep_db_fetch_array($query);
$prods_id = $prods_arr['products_id'];
tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO,'products_id='.$prods_id));
}

that should the fix for that.
Any contributions welcome (we even accept and consider a thank you to be great one for this one).

Good Luck with new shop.
Cheers
Harishyam Services
yahoo: feenix_666

Legend:  Download   Report
Expand All / Collapse All
Only product in category : Product list to product information page hari_shyam 29 Jan 2008  

Hi..

This is my first contribution. Starting out with a simple one.

I frequently get clients asking for this feature. so i thought it would save time and money for the client ( any sop owner ) looking for a fix.

This change to the index.php makes sure that the customer/user is redirected to the products information page in case there is only one product in the particular category.

=======================================
1. find the line:
if (isset($cPath) && tep_not_null($cPath)) {
$categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
$cateqories_products = tep_db_fetch_array($categories_products_query);
if ($cateqories_products['total'] > 0) {

Add in the following code below the above code snippet.

if ($cateqories_products['total'] == 1)
{
$query = tep_db_query("select p2c.products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where categories_id = '" . (int)$current_category_id . "'");
$prods_arr = tep_db_fetch_array($query);
$prods_id = $prods_arr['products_id'];
tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO,'products_id='.$prods_id));
}

that should the fix for that.
Any contributions welcome (we even accept and consider a thank you to be great one for this one).

Good Luck with new shop.
Cheers
Harishyam Services
yahoo: feenix_666