Shopware插件覆盖失败:如何隐藏侧边栏购物车优惠/折扣字段?
解决Shopware侧边栏购物车优惠字段无法隐藏的问题
- 你之前覆盖的
page_checkout_cart_add_promotion是主购物车页面的代码块,和侧边栏(off canvas)购物车不属于同一个模板,所以操作没生效。 - 侧边栏购物车的优惠字段对应的模板路径是
storefront/component/offcanvas/cart.html.twig,目标代码块是component_offcanvas_cart_promotion。
正确的插件代码实现
在你的插件目录下创建路径src/Resources/views/storefront/component/offcanvas/cart.html.twig,写入以下代码:
{% sw_extends '@Storefront/storefront/component/offcanvas/cart.html.twig' %} {% block component_offcanvas_cart_promotion %} {% endblock %}
让修改生效的步骤
- 登录Shopware后台,进入设置->系统->缓存管理,点击「清除缓存」
- 确认你的插件已经激活并完成部署
内容的提问来源于stack exchange,提问作者katioc
相关产品推荐
相关产品推荐

