Calculate the percentage value from the total cart - price [Debut Theme]

Solved
Highlighted
New Member
2 0 1

Hey everyone,

I would like to calculate the percentage value from the total, calculate out of here:

{{ cart.total_price | money_with_currency }}

For example, if the total value of the shopping cart is 100 €, 5% (always the same) should be calculated. So the answer is: 5 €

I have only slight knowledge but it did not work with cart.total_price * 5/100.

Thanks in advance.

Mike

 

 

 

0 Likes
Highlighted
Excursionist
80 19 19

This is an accepted solution.

Hi Mike

I'd imagine it'd be something like:

{{ cart.total_price | divided_by: 100 | times: 5 | money_with_currency }}

The divided_by 100 will get you 1%.

You then times: by 5 to get 5%.

Then the money_with_currency filter displays it in the monetary format you'd expect?

1 Like
Highlighted
New Member
2 0 1

Hi,

thanks for your help and anser.

It works like you described it, great. Exactly for money_with_currency is the corresponding currency (EURO, USD and others)

Best regards,

Mike

1 Like