我在我的应用程序中使用稳定的 spree 2.0.0。在产品展示页面上,所有变体均显示为单选按钮。我只想在下拉菜单中显示它们。有什么想法吗?

谢谢。

最佳答案

注意:特别是当您在应用程序设计中或使用自定义设计进行了广泛的设计更改时,此解决方案将实现Spree“模板替换方法”。看这里

http://guides.spreecommerce.com/developer/view.html

否则,如果u使用的是Spree商店的默认设计或进行了较小的更改,请使用“破坏”方法。

去:

app/views/spree/products/_cart.html.erb。并在购物车表格中写了以下几行

<%= select_tag "products[#{@product.id}]",     options_for_select(@product.variants_and_option_values(current_currency).collect{|v| ["#{variant_options(v)}  #{variant_price(v)}", v.id]})%>

#(if you don't have this file(app/views/spree/products/_cart_form.html.erb) go to github spree2.0.0 branch and use it in your product.)

希望这对您也有用。

谢谢

关于ruby-on-rails - spree 如何在下拉的Ruby on Rails中显示变体?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18076193/

10-12 22:30