I have a product for example a “Hat” that I want to include with two different templates, reason being is I need
two different type of custom liquids on the page.
I can only assign one template to the product and when the user clicks on the product the liquid is only applied to the one product.
I don’t want to duplicate the product because I have many “hat” products"
For example “Hat1” is in “Men Hat” category and “Fishing Hats” I want a custom liquid giving navigation so the user can go back to the main collections by clicking the urls - except I can only assign one template per product so the product either is “Men > Hats & Caps” or “Fishing > Hats & Caps”
To achieve the functionality of having a product like “Hat1” appear in both “Men Hat” and “Fishing Hats” categories with different custom liquids, you can consider the following approach:
Use Tags or Metafields: Instead of assigning a product to multiple templates, use tags or metafields to dynamically render different custom liquids based on the category or context. This way, you can conditionally display different navigation options or content based on the product’s tags or metafields.
Conditional Logic in Liquid: Implement conditional logic within your Liquid templates. You can check for specific tags or metafields and render different sections of the template accordingly. For example, if a product has a tag “Fishing”, you can display the navigation for “Fishing Hats”.
This approach avoids duplicating products and allows you to maintain a single product entry while providing the flexibility to display different content based on the context in which the product is viewed.