简体   繁体   English

疯狂的宝石,无需结帐

[英]Spree gem without checkout

I am using Spree 2.0.4 on Rails 3.2.14. 我在Rails 3.2.14上使用Spree 2.0.4。 I want to build an ecommerce site, but it should not have checkout feature. 我想建立一个电子商务网站,但是它不应该具有结帐功能。 An ecommerce site without checkout doesn't make a lot of sense but it's essentially a B2B model, so retail sales are not going to happen. 没有结帐的电子商务网站没有多大意义,但本质上是B2B模式,因此零售销售不会发生。 I have read through documentation and it shows steps to customize the checkout process, but it's still not clear how to remove this functionality entirely. 我已经阅读了文档 ,并显示了自定义结帐流程的步骤,但仍不清楚如何完全删除此功能。 My requirement is to 我的要求是

  1. No Price display on froent end 前端没有价格显示
  2. No Add to cart, or quantity option 否添加到购物车或数量选项

I would like to use Spree because of it's inventory management and UX modules, which would help me get up and running fast. 我想使用Spree,因为它具有库存管理和UX模块,可以帮助我快速启动和运行。

There is no short way to do this, yet the easiest way would be to just get rid of any reference to check out and quantity in the front-end. 没有捷径可做,但是最简单的方法是摆脱任何参考,以检出前端的数量和数量。 You can do this overriding the views which refers to them, entirely or using deface (deface is more recommended but it also takes time to learn), and just removing any quantity field, price label, add-to-cart or checkout link. 您可以完全或使用deface来覆盖引用它们的视图(建议使用deface,但学习起来也要花一些时间),并且只需删除任何数量字段,价格标签,购物车或结帐链接即可。

However, having worked with Spree for quite a while now, my personal advice would be to fork the spree project from github and selectively remove the features you don't want, both in the frontend, the backend, and the core engine. 但是,与Spree合作已经有一段时间了,我的个人建议是从github分支出spree项目,并选择性地删除前端,后端和核心引擎中不需要的功能。 That would take some extra effort though. 但是,这将需要花费额外的精力。

I haven't used 2.x versions, but I've looked at it and it should be enough to override show.html.erb for products with Deface: 我没有使用过2.x版本,但我看它,它应该足以覆盖show.html.erb产品有污损:

app/overrides/products/show.rb:

 Deface::Override.new(
   virtual_path: 'spree/products/show',
   name: 'Remove cart',
   remove: '[data-hook="cart_form"]')

and same for products index. 与产品索引相同。

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)')")

Beware, I've written above without testing based on my experience with 1.3 version, I don't have any Spree 2.x version installed and I can't do that now, I see they've splitted frontend and backend , so paths might be spree/frontend/app/views/spree/shared_products instead of above, but I doubt it. 当心,根据我在1.3版本上的经验,我上面没有进行测试就编写了上面的代码,我没有安装任何Spree 2.x版本,现在我不能这样做,我看到它们将frontendbackend ,所以路径可能是spree/frontend/app/views/spree/shared_products而不是上面的,但是我对此表示怀疑。

That will of course remove it only visually, you may also try playing with Product class, eg overriding some base method like: 当然,那只会从视觉上将其删除,您也可以尝试使用Product类,例如,覆盖一些基本方法,例如:

Spree::Product.class_eval do
  def on_sale?
    false
  end
end

but again, that's based on 1.3, I'm just pointing you where to look as it could've changed a lot since 1.3. 但同样,它是基于1.3的,我只是指出您要看的地方,因为自1.3以来它可能发生了很大变化。

If you want to get rid of all traces of checkout options you should do as @Miotsu written, as you're going to remove one of basic functions of Spree. 如果要摆脱所有签出选项的痕迹,应按照@Miotsu的说明进行操作,因为这将删除Spree的基本功能之一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM