Converting 'Cart Weight' to kg

Solved
New Member
2 0 0

Hello All

 

I am new here and building a new store and looking to customise the cart & checkout page(s) and need a bit of help please.

 

In the Cart page I managed to add a line to show the total cart weight using the following code..

 

'<div> You have {{ cart.item_count }} {{ cart.item_count | pluralize: 'item', 'items' }} in your cart and your total cart weight is {{cart.total_weight}} g</div>'

That shows something like this;

Screenshot 2019-04-07 at 19.29.20.png

But I need to show the weight in 'kg' rather than in grams. I thought changing the default weight units to 'kg' would do the trick but it didn't.

 

Could the experts please help me with how I can achieve this please?

 

Also, being in a basic Shopify plan, would I be able to show the same message (to show the weight) in the checkout page within the 'Shipping method' section so my customers can select the correct shipping option based on the weight?

 

Thanks in advance.

0 Likes

Success.

Shopify Partner
462 80 94
<div> You have {{ cart.item_count }} {{ cart.item_count | pluralize: 'item', 'items' }} in your cart and your total cart weight is {{cart.total_weight}} g</div>

 

It is pretty easy, change, we just need to divide it by 100

 

{{cart.total_weight}}

into

{{cart.total_weight | divided_by: 100}}

 And of course change g into kg ))))

Author: Hovhannes Sargsyan (aka sarhov).
An individual web developer focused on Shopify development.
Need more help? Feel free to send me a direct message or drop an email shopify@sarhov.com

Website: https://sarhov.com  
Email: shopify@sarhov.com
Skype: @sarhov
Messenger: @sarhov
Telegram: @sarhov
1 Like
New Member
2 0 0

Thank you so much @sarhov , that works a treat.

 

Any advise on how I can show the same in the checkout page?

0 Likes
Highlighted
Shopify Partner
462 80 94

Unfortunately checkout page is not editable, unless you're Shopify plus member. ((

Author: Hovhannes Sargsyan (aka sarhov).
An individual web developer focused on Shopify development.
Need more help? Feel free to send me a direct message or drop an email shopify@sarhov.com

Website: https://sarhov.com  
Email: shopify@sarhov.com
Skype: @sarhov
Messenger: @sarhov
Telegram: @sarhov
0 Likes