Display TRUE weight number (to decimal points) on product page (not rounded).

Display TRUE weight number (to decimal points) on product page (not rounded).

Askew_Jewelers
Visitor
1 0 0

Hello! My Shopify store has been a pleasantly successful addition to my physical location. I am now trying to perfect it.

 

As you may have guessed, we deal in jewelry, and in that market, exact weights are absolutely necessary as the value of precious metals are measured in weight and are high enough that decimal places are very relevant. While I have been able to add a custom liquid code into the product page (based on instructions in this and this forum post) that display the product's weight, it unfortunately rounds the weight to the nearest whole number. Please see attached images. This is unacceptable - the true, exact weight must be displayed for the reasons above.

 

I have attempted to use alternative means / variables listed here and here to no avail - but I am far from proficient in coding, so I could easily be making a simple mistake. Most attempts I have made do not display anything, much less the weight. The code I have gotten to display weight (rounded) are as follows (from the forum posts previous mentioned):

Weight: {{ product.variants.first.weight | weight_with_unit }}
Weight: {% for variant in product.variants %}{{variant.weight | weight_with_unit }}{% endfor %}

The pictures below show the first code working, but both display identical outputs.

 

We have discussed adding the weights to all the descriptions by hand, but as we have hundreds of items and only more coming, it would be a task I would rather not do. All the correct and true weights are already entered into the 'Weight' field under 'Shipping' on their admin product page. So please - help me display the true weight of our items.

 

Pic 1

Despite the weight being entered correctly...

Screenshot 2023-08-03 at 14-39-31 Askew Jewelers · Products · Diamond and Aquamarine Pendant · Shopify.png

 

Pic 2

...it is rounded to the nearest whole number.

Screenshot 2023-08-03 at 14-39-11 Diamond and Aquamarine Pendant.png

 

Thank you in advance for any assistance.

Reply 1 (1)

isabelcecilia
Visitor
1 0 0

Hello, how are you?

after 3 hours trying to figure it out, this is what worked for me:

 

weight_with_unit s
{% if card_product.variants.first.weight != blank %}<- check if not null
{{card_product.variants.first.weight_in_unit | number_with_delimiter}} g
{% endif %}

substitute card_product for product, it should work fine. weight_with_unit should be left out, it doesn`t work with number_with_delimiter, unfortunely... if you find a way to work both out let me know.

best,

isabel