Spree 如何在下拉 Ruby on Rails 中显示变体? [英] Spree how to display variants in drop down Ruby on Rails?

查看:35
本文介绍了Spree 如何在下拉 Ruby on Rails 中显示变体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using spree 2.0.0 stable in my application. On product show page all variants display as a radio buttons. I just want to show them in a drop down. Any thoughts on this?

谢谢.

推荐答案

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

Note: This solution implements Spree "Template Replacement method" especially, when u have extensive design change in your application design or using your custom design. See here

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

否则,如果您使用的是 Spree 商店的默认设计或细微更改,请使用deface"方法.

Otherwise use "deface" method if u are using default design of Spree store or minor changes.

前往:

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

app/views/spree/products/_cart.html.erb. and wrote following line at inside cart Form.

<%= 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.)

希望这也适用于您.

谢谢

这篇关于Spree 如何在下拉 Ruby on Rails 中显示变体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆