Originally Posted by
mc12345678
So fated reply... Anything is possible.
It is particularly easier if you have no linked product, because then every product only exists in one category, and then you can apply css to each product that incorporates the master_categories_id of the product.
The problem comes with product that are linked (single products_id available from more than one category). At this time, when adding a product to the shopping cart, the category id is "lost" regarding the product and therefore, if you have this product in two different categories, the stylesheets for the two different categories result in some "specific" difference, then without the "purchased from" category identified, only the master_category_id category information is available and this may result in the "wrong" stylesheet being applied.
That said, if the purchased from category doesn't matter or the product does or can only exist in one category there are a couple of straight forward ways to obtain the master_category_id of a product. The first is somewhat obvious to consider as it minimizes the lookup needed for a single query. There may be reason/efficiency by performing a "larger" lookup, but I would say that simply depends on the needs of the code.
1) the function zen_get_products_category_id($products_id)
2) the function zen_products_lookup($product_id, 'master_category_id')
If, as the question implies, it is necessary to know from which category the product was purchased, then additional data must be captured along the add-to-cart process so that the 'purchased from' category can be used to hone in the data needed/wanted in order to eliminate the differences of concern.
Of course, will have to also incorporate each of your individual category style sheet "rules" into this master shopping_cart stylesheet either by loading in of those sheets or tried and true copy and paste.
Bookmarks