我試圖檢查某個產品是否位於特定類別中,並在product-list.tpl中更改添加到購物車按鈕的標籤檢查產品是否屬於特定類別?
在這種情況下,我想顯示「Read more Here」的「添加到購物車」,如果產品位於類別ID 14
現在從14類所有產品越來越「添加到購物車」
我跑1.6.0.11
{assign var='associated' value=0}
{foreach Product::getProductCategories($smarty.get.id_product) as $category}
{if in_array($category, 14)}
{assign var='associated' value=1}
{/if}
{/foreach}
{if $associated==1}
{l s='Read more here'}
{else}
{l s='Add to cart'}
{/if}
這適用於PS 1.6.1.5 :-)在product.tpl中,'$ product-> id'更短:-), –