2017-06-14 44 views
1

因此,我正在一个网站上,所有者向慈善机构捐赠一定比例的每个订单。计算从Shopify中花费的总额中捐出了多少

在用户帐户页面的底部是一个部分,显示客户从他们的所有订单中获得了多少捐款。

所以客户在所有订单上花费了100英镑,每笔订单都有2%的捐款。

我该如何使用Liquid来做到这一点?

回答

2
{% 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 --> 
+0

啊!那完美的工作!非常感谢。 – ConduciveMammal

+0

[这是一个有用的资源](https://www.shopify.com.au/partners/shopify-cheat-sheet)如果你想知道你有什么信息访问。 – Buts

+0

噢,我经常使用它。我的问题是我的数学知识是可怕的,所以我不知道如何计算它。但是,谢谢! – ConduciveMammal