如果prices
中的cart
已quantity
,我会根据item
的{{1}}在item
上显示不同的cart
6
中item.quantity
以上price
以上metafield
保存default price
,其他total
显示cart
。知道这一点我想基于那些prices
在//i declare a variable for the subtotal
{% assign subtotal = 0 &}
{% item.quantity >= 6 %}
//if the item qty is greater than 6 i show a different prices, in this case a price saved on a metafield
{% subtotal += item.product.metafields.global.wholesale_price | times:item.quantity %}
{% else %}
{% subtotal+= item.price | times:item.quantity %}
{% endif %}
上显示{{ 'general.cart_info.sub_total' | t }}<span><span class="amount">{{ subtotal | money }}</span></span>
,例如
subtotal += value
最后显示小计
//on the liquid file i added the hidden field with a custom class with the sub-total of that row
{% for item in cart.items %}
{% item.quantity >= 6 %}
<input type="hidden" value="{{ price | times: item.quantity }}" class="subtotals">
{% else %}
<input type="hidden" value="{{ sca_price }}" class="subtotals">
{% endif %}
{% endfor %}
//in the function i calculate de sum of all the rows and show the result on a div called show_subtotal
function calculateSubtotal()
{
var subtotal = parseInt(0);
$('.subtotals').each(function(index, el) {
subtotal += parseInt($(el).val());
});
subtotal = '$'+subtotal;
subtotal = subtotal.slice(0,-2)+'.'+subtotal.slice(-2)
$('.show_subtotal').html(subtotal);
}
正如我所看到的那样wd,ac=raw_input().split(" ")
wd=int(wd)
ac=float(ac)
if(ac<wd):
print(ac)
elif(wd%5==0):
if(ac>wd+0.50):
print(ac-wd-0.50)
else:
print(ac)
else:
print(ac)
不受支持或我使用它错了,有没有办法做到这一点?
被修改
我使用隐藏输入和像这样的js函数做了一个解决方法
Runtime NZEC Error
这项工作,但它不是最好的方法,我应该能够在服务器端这样做。有什么建议吗?
答案 0 :(得分:0)
嗯,再次使用assign
{% assign subtotal = 0 &}
{% item.quantity >= 6 %}
//if the item qty is greater than 6 i show a different prices, in this case a price saved on a metafield
{% assign subtotal = item.product.metafields.global.wholesale_price | times: item.quantity %}
{% else %}
{% assign subtotal = item.price | times: item.quantity %}
{% endif %}