Clearly I have completely overlooked the fact that a linked product is the EXACT same product as in the master category with no linkage to the category you viewed it in. I think this is a big issue for linked products, I am sure there would be many people who would like to know which category the linked product came from. Separate products and attributes would mean a massive database for my site..
So I may have a workaround that I think works well but does mean some hacking (all template files though).
I created a custom text field and managed to insert the category name into this to pass as an attribute of the purchased product.
Here is an overview if interested:-
- I created a Text attribute called Range (which is our category)
- I have hidden this box with "display: none" (the only way to identify it was hack attributes.php and tpl_modules_attributes.php to add a class to each attribute "wrapperAttribsOptions" div to identify it).
- Then I added in custom input type="hidden" box with the name of the above hidden text attribute.
- Using Ultimate SEOs I added the cPath onto the product URLs. Luckily this DOES keep the actual category you are in rather than the master one!
- Then using function zen_get_category_name() I was able to get the Category name from the cPath, which I then inserted as the Value in the hidden input form, which when submitted will submit this value as the textbox attribute.
So this means the category of the linked product is passed to the cart as an attribute of the product which is fine.
The above would be quite straightforward to include, so would be good if next Zencart version allowed you to pass this category info from a linked product.