首先我必须说我是新手,到目前为止我喜欢可用的功能。然而,我在一些我觉得应该很容易的事情上卡住了。我一定是错过了smarty模板引擎是如何工作的。
如果没有亲眼看到,很难解释整个问题。在我们的新网站www.eliquidonline.co.uk上,我正在制作产品列表模板,并希望改变显示价格和广告到购物车区域的外观和感觉。我在产品打折时设计了外观,所以我可以添加之前的价格,折扣金额等,但现在我已经把产品打折了,这个区域没有显示。你可以通过上面的链接看到。
我现在的代码是:
{if (!$PS_CATALOG_MODE AND ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))}
<div class="pricecontainwrapper">
<div class="addpricetag">{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}
{hook h="displayProductPriceBlock" product=$product type='before_price'}
<span class="smalltext">Was </span><span class="smallstrike">{if $product.price_without_reduction > 0 && isset($product.specific_prices) && $product.specific_prices && isset($product.specific_prices.reduction) && $product.specific_prices.reduction > 0}
{hook h="displayProductPriceBlock" product=$product type="old_price"}{displayWtPrice p=$product.price_without_reduction}</span><div class="pricetag">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</div></div><a href="{$product.link|escape:'html':'UTF-8'}" title="{l s='View'}"><div class="addcartpricebutron">Add To cart</div></a>
</div>
{hook h="displayProductPriceBlock" id_product=$product.id_product type="old_price"}
{if $product.specific_prices.reduction_type == 'percentage'}
<div class="pricereduction">SALE -{$product.specific_prices.reduction * 100}% OFF</div>
{/if}
{/if}
{hook h="displayProductPriceBlock" product=$product type="price"}
{hook h="displayProductPriceBlock" product=$product type="unit_price"}
{hook h="displayProductPriceBlock" product=$product type='after_price'}
{/if}
</div>
{/if}
现在我假设smarty模板的if语句之一没有显示所有的代码,但不知道为什么。
如果您的产品在产品管理页面中进行销售。然后您可以访问变量on_sale
。
在foreach循环中:
{foreach from=$products item=product name=products}
<!-- {$product.on_sale} code here -->
{/foreach}
您可以像访问{$product.on_sale}
那样访问变量。这样的:
<div class='{if isset($product.on_sale) && $product.on_sale}your-special-discount-class{/if}'>