Reputation: 483
So I'm working on a website where the owner donates a certain percentage of every order to a charity.
At the bottom of the user's account page is a section that shows the customer how much donations has been made from all of their orders.
So essentially the customer has spent £100 total across all orders and each order has had a 2% donation.
How would I do this using Liquid?
Upvotes: 1
Views: 365
Reputation: 2591
{% assign total = customer.tota_spent %} <!-- if total spent is 100 -->
{% assign percent = 2 %} <!-- and the donation percent is 2 -->
<!-- total divided by 100 would be 1 percent, times by 2 for 2 percent. -->
{% assign donation = total | divided_by: 100 | times: percent %}
{{ donation }}<!-- outputs 2 if the total spent is 100 -->
Upvotes: 2
Reputation: 2925
Sum total price of all orders.. Remove decimals.. Divide by 50..
Links to help you..
Upvotes: 0