prestashop-1.7 - 在购物车中查看产品类别 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}
非常感谢乔纳森
解决方案
推荐阅读
- asp.net - 为什么使用 HTML.ActionLink 而不是 Common 锚点
- sql - SQL中CASE语法的思考过程
- wordpress - 网站中的搜索引擎显示来自某些网站的结果
- git - 在 Sublime Merge 中显示阶段性变化
- c++ - 访问列表向量中的结构
- javascript - eval() 的 Javascript 替代方案
- spring-boot - 使用 Spring AMQP 进行 MockBean 测试和多个使用者\应用程序上下文
- php - 使用cakephp3,如何在路由中自定义方法和动作
- lisp - 在 ACL2 中添加倒数
- javascript - Django - 使用 Ajax 的 POST 方法错误“POST /......./ HTTP/1.1”405 0