|
完整編碼:
{config_load file="$language/lang_$language.conf" section="boxes"}
{if $deny_cart neq 'true'}
{if $empty=='false'}
<h2 class="boxcartheader">{#heading_cart#}</h2>
<div class="boxcartbody">
{foreach name=aussen item=products_data from=$products}
<p>{$products_data.QTY} x
<a href="{$products_data.LINK}">
{$products_data.NAME|truncate:20:"...":true}
</a>
</p>
{/foreach}
<div class="hr"></div>
<p style="text-align:right">
{if $DISCOUNT}{#text_discount#}{$DISCOUNT}<br />{/if}
{$UST}
<strong>{#text_total#}:{$TOTAL}</strong><br />
{if $SHIPPING_INFO}{$SHIPPING_INFO}{/if}
</p>
<div class="hr"></div>
<p style="text-align:right;">
<a href="{$LINK_CART}">
<strong>{#heading_cart#} »</strong>
</a>
</p>
</div>
{else} <!-- cart has no content -->
<h2 class="boxcartheader">{#heading_cart#}</h2>
<div class="boxcartbody">
<p>{#text_empty_cart#}<br />
<a href="{$LINK_CART}">
{#heading_cart#} »
</a>
</p>
</div>
{/if}
{if $ACTIVATE_GIFT=='true'}
{if $GV_AMOUNT neq ''}
<div class="boxcartbody">
<p>{#voucher_balance#}
<div class="hr"></div>{$GV_AMOUNT}
</p>
</div>
{/if}
{/if}
{/if}
1.載入語言定義檔
{config_load file="$language/lang_$language.conf" section="boxes"}
2.語言常數
| 文字
| 常數
|
| 購物車
| {#heading_cart#}
|
| 折扣
| {#text_discount#}
|
| 總計
| {#text_total#}
|
| 您目前還沒有選購任何商品
| {#text_empty_cart#}
|
| 目前禮券餘額:
| {#voucher_balance#}
|
3.變數
| 功能
| 變數
|
| 數量
| {$products_data.QTY}
|
| 商品連結
| {$products_data.LINK}
|
| 商品名稱
| {$products_data.NAME|truncate:20:"...":true}
|
| 折扣
| {$DISCOUNT}
|
| 總計
| {$TOTAL}
|
| 出貨資訊
| {$SHIPPING_INFO}
|
| 購物內容連結
| {$LINK_CART}
|
| 禮券金額
| {$GV_AMOUNT}
|
商品名稱的功能變數{$products_data.NAME|truncate:20:"...":true}是 Smarty 的進階語法,其解釋是:
當商品名稱超過20個英數字元時,就取前20個字元並在尾端加上...符號。
假設你的商品名稱是全中文,而你又希望購物車功能區塊能顯示長一點的中文商品名稱(1個UTF-8中文字=3個英數字元),
可以調整數字以顯示你所要的。
4.迴圈
{foreach name=aussen item=products_data from=$products}
...
{/foreach}
5.判斷式
{if $deny_cart neq 'true'}
...
{/if}
{if $empty=='false'}
...
{else}
...
{/if}
{if $DISCOUNT}
...
{/if}
{if $SHIPPING_INFO}
...
{/if}
{if $ACTIVATE_GIFT=='true'}
...
{/if}
{if $GV_AMOUNT neq ''}
...
{/if}
|