我没有使用过2.x 版本,但我已经看过了,它应该足以覆盖带有 Deface 的产品的show.html.erb:
app/overrides/products/show.rb:
Deface::Override.new(
virtual_path: 'spree/products/show',
name: 'Remove cart',
remove: '[data-hook="cart_form"]')
产品索引也是如此。
app/overrides/shared/_products.rb:
Deface::Override.new(
virtual_path: 'spree/shared/_products',
name: 'Remove price from products index',
remove: "[erb-loud]:contains('display_price(product)')")
请注意,根据我对 1.3 版本的经验,我在上面写的内容没有经过测试,我没有安装任何 Spree 2.x 版本,我现在不能这样做,我看到他们已经分裂 frontend和backend,所以路径可能是spree/frontend/app/views/spree/shared_products 而不是上面的,但我对此表示怀疑。
这当然只会在视觉上删除它,您也可以尝试使用 Product 类,例如覆盖一些基本方法,例如:
Spree::Product.class_eval do
def on_sale?
false
end
end
但同样,这是基于 1.3 的,我只是在向您指出从哪里看,因为自 1.3 以来它可能已经发生了很大变化。
如果你想摆脱结帐选项的所有痕迹,你应该按照@Miotsu 写的那样做,因为你要删除 Spree 的基本功能之一。