Forums/Personified Addon

Different jQuery tmpl based on product type

Shopify Concierge
posted this on July 14, 2011 10:29

Hi there,

I'm using the liquid case/when block to display different forms depending on product type. I'm not too sure how I can modify the cart code to use a different jQuery template based on product type. I don't need to show attributes that don't apply to that product.

If you can provide any kind of example, that would be great.

Thanks.

 

Comments

User photo
Shopify Concierge
Shopify Concierge

What I normally do is create templates for each form and name them according to the product type. E.g.

...
<script id="p9d-row-template-book-labels" type="text/html">
</script>
...
<script id="p9d-row-template-mini-waterproof" type="text/html">
...
</script>
...

Then pass the name of the template through to add_cart_row:

var template = 'p9d-row-template-{{ item.product.type | handleize }}'; 
personified.add_cart_row(, formatter, template);

Cheers, Gavin.

July 14, 2011 19:55.