Products with weight / without weight

simonlegeyt
New Member
2 0 0

I have a site selling fresh food by weight.

I now want to sell, on the same site, kitchen accessories but I don't want the weight to be displayed.

Caroline suggests this can be done by assigning a Product Type then adding some Liquid logic to my theme's templates to display the price per weight when the product belongs to that “product type” and show the unitary price when it belongs to another.

Can anyone tell me how to do this.

All help gratefully received.

Simon

 

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 18.0px; font: 12.0px 'Lucida Grande'; color: #232323}
0 Likes
Jamie
Shopify Staff (Retired)
Shopify Staff (Retired)
5714 0 154

Something roughly like this:

 

{% if product.type == 'Fresh Food' %}
Weight: {% for variant in product.variants %}{{variant.weight | weight_with_unit }}{% endfor %}
{% endif %}

If you have more than one product type that needs weight displayed you could also use a case statement.

 

 

http://shopifyplus.com ::: http://twitter.com/bacchus
0 Likes
simonlegeyt
New Member
2 0 0

Great!

Thanks,

Simon

0 Likes
MCWeDeveloper
Tourist
8 0 0

Hi, i want to do sell food by wheight too but can't figure out howto do it, did you use an app or something like that?

 

0 Likes