Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How do I show products in subcategories - not list subcats by name


lostndazed

Recommended Posts

Hello,

 

I have main categories:

 

Category A

Category B

Category C

 

Inside the main categories I have subcategories.

 

Category A

.. subcategory i

.. subcategory ii

Category B

.. subcategory iii

.. subcategory iv

.. subcategory v

Category C

 

 

Ok so far.

But I need the PRODUCTS in subcategories i and ii to show up on the index page when someone first selects Category A in the side menu.

 

I still want to allow the customer to drill down IN THE SIDE MENU to the subcategories if he/she chooses.

I just don't want to force the customer to keep clicking on the main part of the index page to find a product.

 

How do I make this code show only products that are in the subcategories of Category A, and not list subcategories by name?

 

 

  if (isset($cPath) && strpos('_', $cPath)) {
// check to see if there are deeper categories within the current category

  $category_links = array_reverse($cPath_array);
  for($i=0, $n=sizeof($category_links); $i<$n; $i++) {
	$categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");
	$categories = tep_db_fetch_array($categories_query);
	if ($categories['total'] < 1) {
	  // do nothing, go through the loop
	} else {
	  $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)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");
	  break; // we've found the deepest category the customer is in
	}
  }
} else {
  $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)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");
}

$number_of_categories = tep_db_num_rows($categories_query);

$rows = 0;
while ($categories = tep_db_fetch_array($categories_query)) {
  $rows++;
  $cPath_new = tep_get_path($categories['categories_id']);
  $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
  echo '				<td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . $categories['categories_name'] . '</a></td>' . "\n";
  if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) {
	echo '			  </tr>' . "\n";
	echo '			  <tr>' . "\n";
  }
}

 

Thank you!

Link to comment
Share on other sites

Hello,

 

I have main categories:

 

Category A

Category B

Category C

 

Inside the main categories I have subcategories.

 

Category A

.. subcategory i

.. subcategory ii

Category B

.. subcategory iii

.. subcategory iv

.. subcategory v

Category C

 

Ok so far.

But I need the PRODUCTS in subcategories i and ii to show up on the index page when someone first selects Category A in the side menu.

 

I still want to allow the customer to drill down IN THE SIDE MENU to the subcategories if he/she chooses.

I just don't want to force the customer to keep clicking on the main part of the index page to find a product.

 

How do I make this code show only products that are in the subcategories of Category A, and not list subcategories by name?

 

Thank you!

 

I don't understand why you NEED the products in the subcategories to show up, but hey, that's your thing.

I'm no good at editing PHP but I think you can solve your problem from within the Admin Panel...??

 

Copy the items from subcategories i & ii to Category A.

Then when someone clicks on Category A all the items will display.

Click on subcategory i only subcategory i will display.

You get the idea...

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

Thanks for the idea. It is a good one, but because of the low tech abilities of the store owner, that doesn't work well. Too much potential for confusion... and I'm not sure how Google would see the duplicated products.

 

I don't understand why you NEED the products in the subcategories to show up

 

Because every click loses about 17% of the viewers. I'd like to stop that 17% lose of sales.

The index page has links to the main categories, so when a person clicks to a main category from the index page, I'd like a product list to show up for all the products that main category selected.

 

The categories infobox on the side of the page can work as normal, showing the main links and subcategory links for drilling down into the products.

Link to comment
Share on other sites

Do you want to mark the products shown from the subcategories with the subcategory name to avoid some confusion for the customer?

 

That would be fine.

 

I just need the products to show when the main category has been clicked.

To see what I mean, an example is at example

 

 

When you click on the In The Garden square it will take you to a list of products. (This is good. Customer can start shopping right away, OR use subcategories on the left to drill down.)

 

On the osCommerce sample store:

example

 

When you click on the In The Garden square, it will take you to a list of subcategories. (This is bad. Customer has nothing to draw them into the shopping experience.)

Link to comment
Share on other sites

I got what you mean. It shouldn't be too hard to programm, since the basic logic is already there, just placed somewhere else in the same file. Can't tell you exactly out of the pocket what needs to be done, but it's possible anyways.

Link to comment
Share on other sites

I just need the products to show when the main category has been clicked.

To see what I mean, an example is at example

When you click on the In The Garden square it will take you to a list of products. (This is good. Customer can start shopping right away, OR use subcategories on the left to drill down.)

 

On the osCommerce sample store: example

 

When you click on the In The Garden square, it will take you to a list of subcategories. (This is bad. Customer has nothing to draw them into the shopping experience.)

 

That would be neat to have osC list the products such as eBay does. I am sure it can be done through the PHP coding, how? I don't know as I mentioned before I am just starting to grasp that part of all this.

Just a thought (not sure if it would really work but I think it's along the right track) :blink:

In the code you supplied above I would think you need to change what it is calling for to show.

 

} else {

$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)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");

break; // we've found the deepest category the customer is in

}

}

} else {

$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)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");

}

 

Possibly try changing cd.categories_name to something like c.parent_id or c.categories_id.

Remember to backup your file and that I am only making an educated quess.

 

Another way would be to change the "Whats New For Month" infobox into "Featured Products" box and add whatever items you like into that.

 

That's all I can think of right now.

Let us know how you make out. :thumbsup:

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

Sadly, that did not work. :'(

 

There is probably more than those two instances that need to be changed in your index.php file.

 

Have a look even through the HTML coding for the table layout. If I remember correctly there is bits of code there that also determines what is being displayed.

 

It's a pain in the butt, kind of like looking for a needle in a hay stack.

 

I had a similar problem when I changed the code from displaying the thumbnail image on the product_info.php page. I missed adding p.products_bimage in one line of code out of six. Until I found that one spot the change never worked.

 

Good luck and don't give up just yet. Were there's a will there's a way. ;)

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...