gpt4 book ai didi

php - Smarty 总金额 sum

转载 作者:搜寻专家 更新时间:2023-10-31 20:41:10 25 4
gpt4 key购买 nike

如果我有以下代码,我如何计算最终支付的价格

$Total

:

 {foreach from=$items key=k item=item}
<tr>
<td class="align_left"><strong>{$item.Title}</strong></td>
<td><a href="products/view/{$k}"><img src="products_images/{$item.ImagePath}" width="60" height="60" alt="{$item.Title}" /></a></td>
<td>{$item.quantity}</td>
<td>{$item.Price}<span class="s_currency s_after"> лв.</span></td>
<td>{math equation="x * y" x=$item.Price y=$item.quantity}<span class="s_currency s_after"> лв.</span></td>
</tr>
{/foreach}
<tr class="last">
<td class="align_right" colspan="4"><strong>Всичко:</strong></td>
<td class="s_secondary_color"><span class="s_currency s_before">$</span>{$Total}</td>
</tr>

最佳答案

我不明白你为什么需要它,但是去做吧:

注意:适用于 Smarty 3。

{$Total = 0 }  

{foreach from=$items key=k item=item}
<tr>
<td class="align_left"><strong>{$item.Title}</strong></td>
<td><a href="products/view/{$k}"><img src="products_images/{$item.ImagePath}" width="60" height="60" alt="{$item.Title}" /></a></td>
<td>{$item.quantity}</td>
<td>{$item.Price}<span class="s_currency s_after"> лв.</span></td>
<td>{math equation="x * y" x=$item.Price y=$item.quantity}<span class="s_currency s_after"> лв.</span></td>
{$Total = $Total+ ($item.Price*$item.quantity) }
</tr>
{/foreach}
<tr class="last">
<td class="align_right" colspan="4"><strong>Всичко:</strong></td>
<td class="s_secondary_color"><span class="s_currency s_before">$</span>{$Total}</td>
</tr>

关于php - Smarty 总金额 sum,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21210484/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com