Tuesday 29 April 2008

OSCOMMERCE Hide Categories & Products add on

I was trying to install the contribution for hiding product catergories on a heavily modded Oscommerce store -

this contribution can be found at http://www.oscommerce.com/community/contributions,5907/category,all/search,Hide+Categories+%26+Products

Following the instructions I got everything to work ok except for in the admin area, where we now have a a green and red circle that light up when the folder is active or inactive. After installing the contribution then all buttons would come up red.

the contribution code displaying these items is as follows

[code]

if ($categories['categories_status'] == '1') {
echo tep_image(DIR_WS_IMAGES . 'icon_status_greenl.gif', IMAGE_ICON_STATUS_GREEN, 12, 12) . '  ' . tep_image(DIR_WS_IMAGES . 'icon_status_red_lightl.gif', IMAGE_ICON_STATUS_RED_LIGHT, 12, 12) . '';
} else {
echo '' . tep_image(DIR_WS_IMAGES . 'icon_status_green_lightl.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 12, 12) . '' . '  ' . tep_image(DIR_WS_IMAGES . 'icon_status_redl.gif', IMAGE_ICON_STATUS_RED, 12, 12); }
?>
[/code]


after running test i discovered that the part of the code running this test

$categories['categories_status'] == '1'

was not receiveing any value. So I wrote this hack (albeit ugly and not in the preffered oscommerce format it does work !!)

FIND:
// CATEGORY STATUS
if ($categories['categories_status'] == '1') {

REPLACE WITH

$categories_id = $categories['categories_id'] ;
$selectquery = "SELECT * FROM categories WHERE categories_id = $categories_id ";
$result = mysql_query($selectquery)
or die ("Query failed");
$row = mysql_fetch_array($result);


// CATEGORY STATUS
if ($row['categories_status'] == '1') {

No comments: