Forums / General Questions / Determine if product is in a certain catagory

Determine if product is in a certain catagory

Views: 513

Results 1 to 3 of 3
15 Sep 2015, 2:16 AM
#1
joshs avatar

joshs

New Zenner

Join Date:
Dec 2010
Posts:
15
Plugin Contributions:
0

Determine if product is in a certain catagory

In my old ZC I had done a bit of custom coding...

If a product is located in category A or one of it's sub categories (A1, A2, A3), I want to print a special bit of text on the product page. In v139, this code worked:

if (substr($cPath, 0, strpos($cPath, '_')) == 1) echo 'My special text'

This code does not work in v154. Can someone tell me what might work?

Thank you!

15 Sep 2015, 3:42 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Determine if product is in a certain catagory

JoshS:

In my old ZC I had done a bit of custom coding...

If a product is located in category A or one of it's sub categories (A1, A2, A3), I want to print a special bit of text on the product page. In v139, this code worked:

if (substr($cPath, 0, strpos($cPath, '_')) == 1) echo 'My special text'

This code does not work in v154. Can someone tell me what might work?

Thank you!

what about the ZC function:

zen_product_in_category( $product_id, $cat_id)

Where in your case something like:

if (zen_product_in_category( (int)$_GET['products_id'], 1)) {
  echo 'My special text';
}

Source of the above was basically the online docs (not 100% accurate, but a great starting point):
http://www.zen-cart.com/docs/phpdoc-1-5-0/functions/_includes---functions---functions_categories.php.html
With specific link to:
http://www.zen-cart.com/docs/phpdoc-1-5-0/__filesource/fsource_functions__includesfunctionsfunctions_categories.php.html#a240

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

15 Sep 2015, 4:38 PM
#3
joshs avatar

joshs

New Zenner

Join Date:
Dec 2010
Posts:
15
Plugin Contributions:
0

Re: Determine if product is in a certain catagory

Perfect! Thank you!