Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Code to Get Master Category ID of a Product

Code to Get Master Category ID of a Product

Locked

Views: 3,940

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
15 Dec 2006, 7:20 PM
#1
gems14k avatar

gems14k

New Zenner

Join Date:
Jul 2005
Posts:
95
Plugin Contributions:
0

Code to Get Master Category ID of a Product

From searching I found this:

$category_id = zen_get_products_category_id($_GET['products_id']);

That would give me the category ID of the product. If the product is in the a subcategory, how can I get the master category ID?

Thanks

16 Dec 2006, 1:20 AM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Code to Get Master Category ID of a Product

Do you want the master_categories_id or the parent_id or the immediate categories_id of where you are at? :unsure:

Perhaps if you said what you are trying to do with the results it would help ...

The master_categories_id has a main purpose used in pricing ... this is not the same thing as "what category am I in ..."

16 Dec 2006, 5:52 AM
#3
gems14k avatar

gems14k

New Zenner

Join Date:
Jul 2005
Posts:
95
Plugin Contributions:
0

Re: Code to Get Master Category ID of a Product

Ajeh:

Do you want the master_categories_id or the parent_id or the immediate categories_id of where you are at? :unsure:

Perhaps if you said what you are trying to do with the results it would help ...

The master_categories_id has a main purpose used in pricing ... this is not the same thing as "what category am I in ..."

Thank you for the respond, Ajeh.

Say I have this:

Parent Category: Watches

SubCategory Under Watches: For Her, For Him

If the products are under Watches, I want every product to show "For US Only" in the product info page.

Thank you,

23 Dec 2006, 3:57 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Code to Get Master Category ID of a Product

How about putting something in your product_info template like this:

<?php if (substr($cPath, 0, strpos($cPath, '_')) == 45)  echo 'For U.S. Only'; ?>

(where 45 is the "number" of your top-level "Watches" category)