All Projects → AgilTec → spree_variant_options

AgilTec / spree_variant_options

Licence: other
Spree Variant Options groups your variants by option types and values

Programming Languages

ruby
36898 projects - #4 most used programming language
CSS
56736 projects
HTML
75241 projects
Gherkin
971 projects
javascript
184084 projects - #8 most used programming language

Spree Variant Options Build Status

Spree Variant Options is a very simple spree extension that replaces the radio-button variant selection with groups of option types and values. To get a better idea let's let a few images do the explaining.

When no selection has been made:

Spree Variant Options - No selection

After "Large" is selected, "Large Blue" is out of stock:

Spree Variant Options - Option Type/Value selected

And after "Green" is selected:

Spree Variant Options - Variant Selcted

To see it in action, follow the steps for "Demo" below.


Installation

If you don't already have an existing Spree site, click here then come back later... You can also read the Spree docs here...

To install Spree Variant Options, just add the following to your Gemfile:

# Spree 1.3.X
gem 'spree_variant_options', :git => 'git://github.com/sbounmy/spree_variant_options.git', :branch => "1-3-stable"
# Spree 2.0.X
gem 'spree_variant_options', :git => 'git://github.com/sbounmy/spree_variant_options.git', :branch => "2-0-stable"
# Spree 2.4.X
gem 'spree_variant_options', :git => 'git://github.com/AgilTec/spree_variant_options.git', :branch => "2-4-stable"
# Spree 3.0.X
gem 'spree_variant_options', :git => 'git://github.com/AgilTec/spree_variant_options.git', :branch => "3.0.0"

If you're on an older version of Spree, please reference the Versionfile for your Spree version.

Now, bundle up with:

bundle

Next, run the install generator to copy the necessary migration to your project and migrate your database:

rails g spree_variant_options:install
rake db:migrate

Configuration Options

Spree Variant Options comes with some handy options:

  • allow_select_outofstock (default : false) When using extension like (spree_wishlist), you might want to allow your customer to add out of stock product by selecting out of stock variant options :

      <%= form_for Spree::WishedProduct.new, :html => {:"data-form-type" => "variant"} do |f| %>
        <%= f.hidden_field :variant_id, :value => @product.master.id %>
        <button type="submit" class="medium blue awesome">
          <%= t(:add_to_wishlist) %>
        </button>
      <% end %>

    By setting allow_select_outofstock to true, when an user selects variant options it will automatically update any form's input variant_id with an data-form-type="variant" attribute.

  • default_instock (default: false) If this is option is set to true, it will automatically preselect in-stock variant options.

  • main_option_type_id (default: 1) This is the option type id that will be use for showing each variant in the home.

  • main_option_type_label (default: 'color') This is the option type label that will be use as URL parameter to preselect the option in the product show page.

These configuration options can be set in a config/initializers/spree_variant_options.rb file for example :

SpreeVariantOptions::VariantConfig.allow_select_outofstock = true
SpreeVariantOptions::VariantConfig.default_instock = true

Versions

Spree Variant Options is compatible with Spree 0.30.x through 1.1.x. Please reference Versionfile for more details.


Testing

Clone this repo to where you develop, bundle up, then run `dummier' to get the show started:

git clone git://github.com/citrus/spree_variant_options.git
cd spree_variant_options
bundle install
bundle exec dummier

# cucumber/capybara
bundle exec cucumber

# test/unit
bundle exec rake test

# both
bundle exec rake

POW!


Demo

You can easily use the test/dummy app as a demo of spree_variant_options. Just cd to where you develop and run:

git clone git://github.com/citrus/spree_variant_options.git
cd spree_variant_options
cp test/dummy_hooks/after_migrate.rb.sample test/dummy_hooks/after_migrate.rb
bundle install
bundle exec dummier
cd test/dummy
rails s

Contributors

If you'd like to help out feel free to fork and send me pull requests!


License

Copyright (c) 2011 - 2012 Spencer Steffen and Citrus, released under the New BSD License All rights reserved.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].