Solved

Can I display cart weight in kg on Shopify's checkout page?

QA
Tourist
6 0 2

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.

Accepted Solution (1)

sarhov
Shopify Expert
489 85 164

This is an accepted solution.

<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)
Email: shopify@sarhov.com
Website: https://sarhov.com
Try Shopify free for 14 days,

View solution in original post

Replies 4 (4)

sarhov
Shopify Expert
489 85 164

This is an accepted solution.

<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)
Email: shopify@sarhov.com
Website: https://sarhov.com
Try Shopify free for 14 days,

QA
Tourist
6 0 2

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

 

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

sarhov
Shopify Expert
489 85 164

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

Author: Hovhannes Sargsyan (aka sarhov)
Email: shopify@sarhov.com
Website: https://sarhov.com
Try Shopify free for 14 days,

james_tm
Shopify Partner
4 1 7

Doesn't it need to be divided by 1000? 1kg = 1000g.

 

{% assign cart_total_weight = cart.total_weight | divided_by: 1000 %}