Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product in Categories Box 2.3.1


jascoaut

Recommended Posts

I have installed 2.3.1 and was wanting to have a product listed in the categories box,

so when i click on it it goes direct to the individual product, is this possible?

My old version was set up this way to display my automotive service options and costs.

Link to comment
Share on other sites

You can link to anything.

 

So you want a link in the categories box that goes straight to the product info page?

:unsure:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

You can link to anything.

 

So you want a link in the categories box that goes straight to the product info page?

:unsure:

Yes i want to go straight to product info page.

ie: I click on oil change service in top left catergries box and i want it to go to

full page of product with price as in my old site

 

http://www.jascoautomotive.com/workshop

Link to comment
Share on other sites

/catalog/includes/modules/boxes/bm_categories.php

 

Find this line of code:

 

      $this->tep_show_category($first_element);

AFTER that line ADD this code:

 

 

      $pid = '27'  // <== change this number to be the product id you want to link to
     $categories_string .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $pid) . '">' . tep_get_products_name($pid, (int)$languages_id) . '</a>';

 

BACKUP THE FILE BEFORE MAKING EDITS.

 

When people post links to sites I make it a habit to test them for "lapses in security".

 

I've been banned from more sites than Carter has little liver pills...

:blush:

 

Anyway... For what it's worth...

 

I tested the admin at the link you posted and my Antivirus says it's infected with a javascript iframe trojan horse...

:'(

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

MY BAD!

:o

 

The first line of new code needs to be:

 

    $pid = '27';  // <== change this number to be the product id you want to link to 

(removed the semicolon by accident)

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

  • 9 months later...

Hi there, I am having a similar problem - I would like my categories page to link directly to one of the products inside, ( my categories only have one with several accesory products that i have linked up view cross sell, so it feels redundant to to have the user click on a category only to forced to click again to get to the product purchase page.) I have tried your suggestion but it doesn't seem to do anything on my page... Please any help would be greatly appreciated!

Link to comment
Share on other sites

different ways to achieve what the OP wants. here's an example:

if (tep_db_num_rows(tep_db_query($listing_sql)) == 1) {
$listing = tep_db_fetch_array(tep_db_query($listing_sql));
$url = tep_href_link(FILENAME_PRODUCT_INFO, '&products_id=' . $listing['products_id']);
echo '<script type="text/javascript">';
  echo 'window.location.href="'.$url.'";';
  echo '</script>';
  echo '<noscript>';
  echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
  echo '</noscript>';
}

the code should be added at the top of the module product_listing.php. code is provided as is and no attempt to optimise is made. do not try to use tep_redirect, which could be problematic.

Ken

commercial support - unProtected channel, not to be confused with the forum with same name - open to everyone who need some professional help: either PM/email me, or go to my website (URL can be found in my profile).

over 20 years of computer programming experience.

Link to comment
Share on other sites

just put the above code into action, which can be seen here:

http://www.uddwebsites.co.uk/osc231/index.php

as you will see, if a cattegory (including any sub-cat) contains only one product, it will go straight to the product info page.

 

Ken

 

ps. note that some browsers may give you a product not found error, this is because the "&" in the url. to solve this problem, add one line just above the first "echo":

 

$url = str_ireplace('&','&',$url);

 

Ken

commercial support - unProtected channel, not to be confused with the forum with same name - open to everyone who need some professional help: either PM/email me, or go to my website (URL can be found in my profile).

over 20 years of computer programming experience.

Link to comment
Share on other sites

Have no idea why this won't work for me - in fact, i can't seem to figure out what the bx_categories page dose - as a test i've completely deleted the code, uploaded, and can't see anything being effected. (it's all restored to what it was before now)

 

here is the page with the links i'm trying to change:

 

http://clairepettibone.com/heirloom/shop/index.php/cPath/34

 

login:[email protected]

password nataliya

 

I want it take us straight to one of the products instead of going to the subcategory page.. so for eample, clicking on the first image (leighton) should take us to http://clairepettibone.com/heirloom/shop/product_info.php/cPath/34_21/products_id/31 instead of the "leighton" category...

Link to comment
Share on other sites

  • 7 months later...

/catalog/includes/modules/boxes/bm_categories.php

 

Find this line of code:

 

 $this->tep_show_category($first_element);

AFTER that line ADD this code:

 

 

 $pid = '27' // <== change this number to be the product id you want to link to
$categories_string .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $pid) . '">' . tep_get_products_name($pid, (int)$languages_id) . '</a>';

 

BACKUP THE FILE BEFORE MAKING EDITS.

 

When people post links to sites I make it a habit to test them for "lapses in security".

 

I've been banned from more sites than Carter has little liver pills...

blush.gif

 

Anyway... For what it's worth...

 

I tested the admin at the link you posted and my Antivirus says it's infected with a javascript iframe trojan horse...

:'(

 

Germ, is it possible to use this coding to link a category to one of the pages instead of a product id? Like, for example, if I want to link to the "specials" page?

Link to comment
Share on other sites

  • 2 months later...

red text is where I tried to update

 

 

I'm trying to actually make mine go to another link. I've tried the posted suggestions but not working.

My site is http://www.materialgirlhairsalon.com/catalog/index.php

 

I'm trying to make SALON go to salon.php and etc

 

 

 

Here is the file

 

<?php

/*

$Id$

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2010 osCommerce

 

Released under the GNU General Public License

*/

 

class bm_categories {

var $code = 'bm_categories';

var $group = 'boxes';

var $title;

var $description;

var $sort_order;

var $enabled = false;

var $pages;

 

function bm_categories() {

$this->title = MODULE_BOXES_CATEGORIES_TITLE;

$this->description = MODULE_BOXES_CATEGORIES_DESCRIPTION;

 

if ( defined('MODULE_BOXES_CATEGORIES_STATUS') ) {

$this->sort_order = MODULE_BOXES_CATEGORIES_SORT_ORDER;

$this->enabled = (MODULE_BOXES_CATEGORIES_STATUS == 'True');

$this->pages = MODULE_BOXES_CATEGORIES_DISPLAY_PAGES;

$this->group = ((MODULE_BOXES_CATEGORIES_CONTENT_PLACEMENT == 'Left Column') ? 'boxes_column_left' : 'boxes_column_right');

}

}

 

 

function tep_show_category($counter, $count) {

global $tree, $categories_string, $cPath_array;

 

if ($count == 0 ) $kk=''; else $kk='';

$count++;

$categories_string .= '<li '.$kk.' class="htooltip">';

$categories_string .= '<div class="div_2">';

 

 

for ($i=0; $i<$tree[$counter]['level']; $i++) {

$categories_string .= '<div class="div">';

}

 

 

$categories_string .= '<a href="';

 

if ($tree[$counter]['parent'] == 0) {

$cPath_new = 'cPath=' . $counter;

} else {

$cPath_new = 'cPath=' . $tree[$counter]['path'];

}

if ($tree[$counter]['image'] != '') {

$categories_img = ' rel="'.DIR_WS_IMAGES . $tree[$counter]['image'].'"';

} else {

$categories_img = '';

}

 

$categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '"' . $categories_img . '>'.tep_draw_box_list_top() . '';

 

 

 

if (isset($cPath_array) && in_array($counter, $cPath_array)) {

$categories_string .= '<b>';

}

 

// display category name

$categories_string .= $tree[$counter]['name'];

 

if (isset($cPath_array) && in_array($counter, $cPath_array)) {

$categories_string .= '</b>';

}

 

if (tep_has_category_subcategories($counter)) {

$categories_string .= '<span class="category_arrow"></span>';

}

 

 

 

if (SHOW_COUNTS == 'true') {

$products_in_category = tep_count_products_in_category($counter);

if ($products_in_category > 0) {

$categories_string .= ' (' . $products_in_category . ')';

}

}

$categories_string .= ''.tep_draw_box_list_bottom() . /*tep_image(DIR_WS_IMAGES .$tree[$counter]['image'], $tree[$counter]['name'], HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT) . */'</a>';

for ($i=0; $i<$tree[$counter]['level']; $i++) {

$categories_string .= '</div>';

}

$categories_string .= '</div>';

$categories_string .= '</li>';

$categories_string .= '';

 

if ($tree[$counter]['next_id'] != false) {

$this->tep_show_category($tree[$counter]['next_id'], $count);

}

}

 

function getData() {

global $categories_string, $tree, $languages_id, $cPath, $cPath_array;

 

$categories_string = '';

$tree = array();

 

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

while ($categories = tep_db_fetch_array($categories_query)) {

$tree[$categories['categories_id']] = array('name' => $categories['categories_name'],

'image' => $categories['categories_image'],/* ***************** */

'parent' => $categories['parent_id'],

'level' => 0,

'path' => $categories['categories_id'],

'next_id' => false);

 

if (isset($parent_id)) {

$tree[$parent_id]['next_id'] = $categories['categories_id'];

}

 

$parent_id = $categories['categories_id'];

 

if (!isset($first_element)) {

$first_element = $categories['categories_id'];

}

}

 

if (tep_not_null($cPath)) {

$new_path = '';

reset($cPath_array);

while (list($key, $value) = each($cPath_array)) {

unset($parent_id);

unset($first_id);

unset($image_id);

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$value . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

if (tep_db_num_rows($categories_query)) {

$new_path .= $value;

while ($row = tep_db_fetch_array($categories_query)) {

$tree[$row['categories_id']] = array('name' => $row['categories_name'],

'image' => $row['categories_image'],/* ***************** */

'parent' => $row['parent_id'],

'level' => $key+1,

'path' => $new_path . '_' . $row['categories_id'],

'next_id' => false);

 

if (isset($parent_id)) {

$tree[$parent_id]['next_id'] = $row['categories_id'];

}

 

$parent_id = $row['categories_id'];

 

if (!isset($first_id)) {

$first_id = $row['categories_id'];

}

 

$last_id = $row['categories_id'];

}

$tree[$last_id]['next_id'] = $tree[$value]['next_id'];

$tree[$value]['next_id'] = $first_id;

$new_path .= '_';

} else {

break;

}

}

}

 

$this->tep_show_category($first_element, $count);

 

 

$parent_id = '2' // <== change this number to be the product id you want to link to

$categories_string .= '<a href="http://www.materialgirlhairsalon.com/catalog/contact_us.php"' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $pid) . '">' . /tep_get_products_name($pid, (int)$languages_id) . '</a>';

 

 

$data = '<div class="infoBoxWrapper list">' . tep_draw_box_wrapper_top() .

' <div class="infoBoxHeading">' . tep_draw_box_title_top() . MODULE_BOXES_CATEGORIES_BOX_TITLE . tep_draw_box_title_bottom() . '</div>' .

' <div class="infoBoxContents">' . tep_draw_box_content_top() . '<ul class="categories">' . $categories_string . '</ul>' . tep_draw_box_content_bottom() . '</div>' .

'' . tep_draw_box_wrapper_bottom() . '</div>';

// <li class="htooltip"><div class="div_2"><div class="list_bg"></div><a href="' . tep_href_link(FILENAME_TOPSELLERS_PRODUCTS) . '">'. MODULE_BOXES_CATEGORIES_BEST_SELLERS . '</a></div></li>';

 

return $data;

}

 

function execute() {

global $SID, $oscTemplate;

 

if ((USE_CACHE == 'true') && empty($SID)) {

$output = tep_cache_categories_box();

} else {

$output = $this->getData();

}

 

$oscTemplate->addBlock($output, $this->group);

}

 

function isEnabled() {

return $this->enabled;

}

 

function check() {

return defined('MODULE_BOXES_CATEGORIES_STATUS');

}

 

function install() {

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Categories Module', 'MODULE_BOXES_CATEGORIES_STATUS', 'True', 'Do you want to add the module to your shop?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Placement', 'MODULE_BOXES_CATEGORIES_CONTENT_PLACEMENT', 'Left Column', 'Should the module be loaded in the left or right column?', '6', '1', 'tep_cfg_select_option(array(\'Left Column\', \'Right Column\'), ', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_BOXES_CATEGORIES_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Display in pages.', 'MODULE_BOXES_CATEGORIES_DISPLAY_PAGES', 'all', 'select pages where this box should be displayed. ', '6', '1','tep_cfg_select_pages(' , now())");

}

 

function remove() {

tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");

}

 

function keys() {

return array('MODULE_BOXES_CATEGORIES_STATUS', 'MODULE_BOXES_CATEGORIES_CONTENT_PLACEMENT', 'MODULE_BOXES_CATEGORIES_SORT_ORDER','MODULE_BOXES_CATEGORIES_DISPLAY_PAGES');

Link to comment
Share on other sites

  • 4 weeks later...

Have same issue/want...

 

I want to have a catagory button link to a static php page either I create or one of the ones that come with the oscommerce. IE privacy.php page.

He who sits in jelly, has ass in jam.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...