Weight grams (g) to pounds (lbs) conversion

New Member
1 0 0

Hey there,

In my "fulfilment request" notification email, I noticed that the weight reported is in grams (g), and wanted to convert to pounds (lbs).  My store front is set up to report in pounds, my vendors are setup for pounds, but could convert manually, but it seems burdonsome.

I searched to see if there was native liquid code to convert, but didn't come across any. Or the solutions seemed confusing. So I am using this:

New:  <p>Pounds:  {{ line.line_item.grams | times: 0.00220462 | round: 1 }}</p>
Old:  <p>Grams: {{ line.line_item.grams }}</p>

This takes the reported grams (680g), multiplies by 0.00220462 to convert to pounds and then rounds to nearest tenth, to get 1.5 lbs 

Just wanted to share in case anyone else is looking, or has a better option.

Thanks,

Ming

0 Likes
Tourist
11 0 0

Thanks!  better than nothing!  I was looking for a filter, such as {{ item.grams | weight_in_pounds_and_ounces }} because that is so obvious. Sometimes it seems like the designers of liquid never actually tried to use it.  

0 Likes
Tourist
11 0 0

heh. I was wrong.  Actually there is a builtin filter called "weight_with_units:".   

0 Likes