Help with code to check if a product is associated with a hidden category

Hi,



I'm moving my store from a hosted package to CS Cart. I'm stuck on one method I used in my previous site to check if a product is associated with a hidden category and run specific code if true.



My existing example can be found here: [url=“domain for sale”]domain for sale



You can see the certificate images and wash icons are all dynamically presented according to the assocaited category membership of that product.



Can anyone guide me as to the best way of achieving a similar function with CS?



Many thanks,

Joel

In cs-cart you would generally use Product Features for this type of thing.

If you don't want any text (only images) then just don't have a name or description associated with the feature.

[quote name='tbirnseth' timestamp='1319752814' post='124712']

In cs-cart you would generally use Product Features for this type of thing.

If you don't want any text (only images) then just don't have a name or description associated with the feature.

[/quote]



Thanks for the quick reply.



OK, so experimenting with the Product Feature it isn't quite so striking a mechanism as I'd liked - especially as it is in it's own tab. However, even so I can't quite understand how to only show the image rather than the text.



Please see this demo example as to how the feature currently looks…[url=“http://louisbee-online.net/index.php?dispatch=products.view&product_id=1”]http://louisbee-online.net/index.php?dispatch=products.view&product_id=1[/url]



It would be great to achieve the functionality seen here (in terms of the washing & certificate logos): [url=“domain for sale”]domain for sale



It would be good to understand the image only feature tab issue anyway as I may well have alternative plans for that too…



Thanks again.

If you want a specific layout/design, you might have to customize the templates to suit your need. But you should probably familiarize yourself with “hooks” in cs-cart. Will save you a bunch of issues at upgrade time.



The features associated with a product are part of the $products array. So you should be able to get to the image URL for the feature only if that's all you want to use and then just use a hook (if possible) to display the image of the product feature wherever you want it.



Note that if a pre-defined hook does not exist, it's very easy to just add one to a template (be sure to comment your change for easier resolution of conflicts during upgrades in the future).

Thanks again for your reply.



OK, so I've looked at the hooks and read through the fn.catalog.php but I cannot seem to find a hook that will allow me to query the category information when searching with a product ID.



Would you (or anyone reading this) be prepared to perhaps quote for creating a hook for this specific purpose (as detailed in my previous post)? I just need the hook created and shown how to use it and I'm fairly sure I can then code the rest?



Thanks.

Not clear what action you want to tap into… You stated product detail page previously but now you're talking about search results (they are different since one is 1 possible result and the other is many possible results).



You are going to want to use 2 hooks. One at the PHP level to identify the category and do whatever queries you need to do in order to get the feature images and then set the path to those images in a template variable.



Then you're going to need a template hook that can be sensitive to the template variable you set and produce the appropriate layout (divs, img, etc. tags) to present the images as you want.



If you only want to do this on the product detail page it is a simpler task. If you want your feature images to show on product listing (like search results) then there are several templates that may need to utilize the same hook for displaying your feature images.

[quote name='tbirnseth' timestamp='1319833054' post='124791']

If you only want to do this on the product detail page it is a simpler task.

[/quote]



Exactly, just the product detail page needs to have this code. It's purely to have an automated mechanism to display certain images, when exploring the product page, according to category & subcategory (or feature if it's easier) membership.



My existing database of goods from the live store has the items already associated with categories so ultimately it is easier for me to deal with those items if I continue to keep the categories as the trigger for the images. But I'm not averse to switching this to Features if the code already exists or is easier/faster to implement.



Many thanks,