首页 > 解决方案 > 在购物车中查看产品类别 Prestashop 1.7

问题描述

为了在“添加到购物车”按钮上设置一个条件,它将显示:如果类别 3 的产品在购物车中,则“添加到购物车”按钮将在其他类别的产品上不可用。

为此,我想检索购物车中存在的产品类别的 ID

我有一些看起来像的东西,但仅适用于篮子中已经存在的产品:

{$ in_cart = 0}
{foreach from = $ cart ['products'] item = 'cart_product'}
   {if $ cart_product ['id_product'] == $ product.id}
     {$ in_cart = 1}
   {/ if}
{/ foreach}

{if $ in_cart}
   {l s = 'Already in cart' d = 'Shop.Theme.Actions'}
{else}
   {l s = 'Add to cart' d = 'Shop.Theme.Actions'}
{/ if}

非常感谢乔纳森

标签: prestashop-1.7

解决方案


推荐阅读