Giter Club home page Giter Club logo

spree_variant_options's Introduction

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.

spree_variant_options's People

Contributors

argami avatar baracek avatar citrus avatar danmorin avatar iangreenleaf avatar mvidaurre avatar rbrown avatar sbounmy avatar tiagoamaro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

spree_variant_options's Issues

Can't added or edit product images

Here is my Gem file:

source 'https://rubygems.org'

gem 'rails', '4.2.2'
gem 'mysql2'
gem 'sass-rails', '> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '
> 4.1.0'
gem 'therubyracer', platforms: :ruby
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '> 2.0'
gem 'sdoc', '
> 0.4.0', group: :doc
gem 'bcrypt', '> 3.1.7'
gem 'whenever', require: false # task scheduler
gem 'mina-unicorn', require: false # deployment mina integration with unicorn
gem 'aws-sdk', '
> 1.61.0' # image upload to s3 (investigate on new version)
gem 'paperclip', '> 4.2' # image resizer used by s3 (investigate on new version)
gem 'spree', '
> 3.0.0.rc4'
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '3-0-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'
gem 'spree_multi_currency', github: 'spree-contrib/spree_multi_currency', branch: '3-0-stable'
gem 'spree_related_products', github: 'spree-contrib/spree_related_products', branch: '3-0-stable'
gem 'spree_paypal_express', github: 'spree-contrib/better_spree_paypal_express', branch: '3-0-stable'
gem 'spree_wishlist', github: 'spree-contrib/spree_wishlist', branch: '3-0-stable'
gem 'spree_static_content', github: 'spree/spree_static_content', branch: '3-0-stable'
gem 'spree_editor', github: 'spree-contrib/spree_editor', branch: '3-0-stable'
gem 'spree_slider', github: 'spree-contrib/spree_slider', branch: '3-0-stable'
gem 'spree_mail_settings', github: 'spree-contrib/spree_mail_settings', branch: '3-0-stable'
gem 'spree_variant_options', :git => 'git://github.com/AgilTec/spree_variant_options.git', :branch => "3.0.0"

group :production do
gem 'unicorn'
end

after a multiple of:
/var/www/gnossem-3.0/current/vendor/bundle/ruby/2.2.0/bundler/gems/spree_variant_options-998730136f77/app/controllers/spree/admin/images_controller_decorator.rb:6:in `load_edit_data'

It returned this error.

....
/var/www/gnossem-3.0/current/vendor/bundle/ruby/2.2.0/bundler/gems/spree_variant_options-998730136f77/app/controllers/spree/admin/images_controller_decorator.rb:6:in load_edit_data' /var/www/gnossem-3.0/shared/bundle/ruby/2.2.0/bundler/gems/spree_variant_options-998730136f77/app/controllers/spree/admin/images_controller_decorator.rb:6:inload_edit_data'
activesupport (4.2.2) lib/active_support/callbacks.rb:432:in block in make_lambda' activesupport (4.2.2) lib/active_support/callbacks.rb:145:incall'
activesupport (4.2.2) lib/active_support/callbacks.rb:145:in block in halting_and_conditional' activesupport (4.2.2) lib/active_support/callbacks.rb:504:incall'
activesupport (4.2.2) lib/active_support/callbacks.rb:504:in block in call' activesupport (4.2.2) lib/active_support/callbacks.rb:504:ineach'
activesupport (4.2.2) lib/active_support/callbacks.rb:504:in call' activesupport (4.2.2) lib/active_support/callbacks.rb:92:in_run_callbacks'
activesupport (4.2.2) lib/active_support/callbacks.rb:776:in _run_process_action_callbacks' activesupport (4.2.2) lib/active_support/callbacks.rb:81:inrun_callbacks'
actionpack (4.2.2) lib/abstract_controller/callbacks.rb:19:in process_action' actionpack (4.2.2) lib/action_controller/metal/rescue.rb:29:inprocess_action'
actionpack (4.2.2) lib/action_controller/metal/instrumentation.rb:32:in block in process_action' activesupport (4.2.2) lib/active_support/notifications.rb:164:inblock in instrument'
activesupport (4.2.2) lib/active_support/notifications/instrumenter.rb:20:in instrument' activesupport (4.2.2) lib/active_support/notifications.rb:164:ininstrument'
actionpack (4.2.2) lib/action_controller/metal/instrumentation.rb:30:in process_action' actionpack (4.2.2) lib/action_controller/metal/params_wrapper.rb:250:inprocess_action'
activerecord (4.2.2) lib/active_record/railties/controller_runtime.rb:18:in process_action' actionpack (4.2.2) lib/abstract_controller/base.rb:137:inprocess'
actionview (4.2.2) lib/action_view/rendering.rb:30:in process' actionpack (4.2.2) lib/action_controller/metal.rb:196:indispatch'
actionpack (4.2.2) lib/action_controller/metal/rack_delegation.rb:13:in dispatch' actionpack (4.2.2) lib/action_controller/metal.rb:237:inblock in action'
actionpack (4.2.2) lib/action_dispatch/routing/route_set.rb:74:in call' actionpack (4.2.2) lib/action_dispatch/routing/route_set.rb:74:indispatch'
actionpack (4.2.2) lib/action_dispatch/routing/route_set.rb:43:in serve' actionpack (4.2.2) lib/action_dispatch/journey/router.rb:43:inblock in serve'
actionpack (4.2.2) lib/action_dispatch/journey/router.rb:30:in each' actionpack (4.2.2) lib/action_dispatch/journey/router.rb:30:inserve'
actionpack (4.2.2) lib/action_dispatch/routing/route_set.rb:819:in call' railties (4.2.2) lib/rails/engine.rb:518:incall'
railties (4.2.2) lib/rails/railtie.rb:194:in public_send' railties (4.2.2) lib/rails/railtie.rb:194:inmethod_missing'
actionpack (4.2.2) lib/action_dispatch/routing/mapper.rb:51:in serve' actionpack (4.2.2) lib/action_dispatch/journey/router.rb:43:inblock in serve'
actionpack (4.2.2) lib/action_dispatch/journey/router.rb:30:in each' actionpack (4.2.2) lib/action_dispatch/journey/router.rb:30:inserve'
actionpack (4.2.2) lib/action_dispatch/routing/route_set.rb:819:in call' warden (1.2.3) lib/warden/manager.rb:35:inblock in call'
warden (1.2.3) lib/warden/manager.rb:34:in catch' warden (1.2.3) lib/warden/manager.rb:34:incall'
rack (1.6.4) lib/rack/etag.rb:24:in call' rack (1.6.4) lib/rack/conditionalget.rb:25:incall'
rack (1.6.4) lib/rack/head.rb:13:in call' actionpack (4.2.2) lib/action_dispatch/middleware/params_parser.rb:27:incall'
actionpack (4.2.2) lib/action_dispatch/middleware/flash.rb:260:in call' rack (1.6.4) lib/rack/session/abstract/id.rb:225:incontext'
rack (1.6.4) lib/rack/session/abstract/id.rb:220:in call' actionpack (4.2.2) lib/action_dispatch/middleware/cookies.rb:560:incall'
activerecord (4.2.2) lib/active_record/query_cache.rb:36:in call' activerecord (4.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:649:incall'
actionpack (4.2.2) lib/action_dispatch/middleware/callbacks.rb:29:in block in call' activesupport (4.2.2) lib/active_support/callbacks.rb:88:incall'
activesupport (4.2.2) lib/active_support/callbacks.rb:88:in _run_callbacks' activesupport (4.2.2) lib/active_support/callbacks.rb:776:in_run_call_callbacks'
activesupport (4.2.2) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (4.2.2) lib/action_dispatch/middleware/callbacks.rb:27:incall'
actionpack (4.2.2) lib/action_dispatch/middleware/remote_ip.rb:78:in call' actionpack (4.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:incall'
actionpack (4.2.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in call' railties (4.2.2) lib/rails/rack/logger.rb:38:incall_app'
railties (4.2.2) lib/rails/rack/logger.rb:20:in block in call' activesupport (4.2.2) lib/active_support/tagged_logging.rb:68:inblock in tagged'
activesupport (4.2.2) lib/active_support/tagged_logging.rb:26:in tagged' activesupport (4.2.2) lib/active_support/tagged_logging.rb:68:intagged'
railties (4.2.2) lib/rails/rack/logger.rb:20:in call' actionpack (4.2.2) lib/action_dispatch/middleware/request_id.rb:21:incall'
rack (1.6.4) lib/rack/methodoverride.rb:22:in call' rack (1.6.4) lib/rack/runtime.rb:18:incall'
activesupport (4.2.2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in call' rack (1.6.4) lib/rack/sendfile.rb:113:incall'
railties (4.2.2) lib/rails/engine.rb:518:in call' railties (4.2.2) lib/rails/application.rb:164:incall'
rack (1.6.4) lib/rack/tempfile_reaper.rb:15:in call' rack (1.6.4) lib/rack/commonlogger.rb:33:incall'
rack (1.6.4) lib/rack/chunked.rb:54:in call' rack (1.6.4) lib/rack/content_length.rb:15:incall'
unicorn (4.9.0) lib/unicorn/http_server.rb:580:in process_client' unicorn (4.9.0) lib/unicorn/http_server.rb:674:inworker_loop'
unicorn (4.9.0) lib/unicorn/http_server.rb:529:in spawn_missing_workers' unicorn (4.9.0) lib/unicorn/http_server.rb:140:instart'
unicorn (4.9.0) bin/unicorn:126:in <top (required)>' /var/www/gnossem-3.0/current/vendor/bundle/ruby/2.2.0/bin/unicorn:23:inload'
/var/www/gnossem-3.0/current/vendor/bundle/ruby/2.2.0/bin/unicorn:23:in `

'

But it seems to work on local.

Can't install 3.0.0.beta

Hi,
I can't install spree_variant_options 3.0.0.beta on spree 3
my GemFile is as follow:

source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

gem 'spree', github: 'spree/spree'
gem 'spree_variant_options', :git => 'git://github.com/AgilTec/spree_variant_options.git', :branch => "3-0-0-beta"

the error I get is:

fatal: ambiguous argument '3-0-0-beta': unknown revision or path not in the working tree

I know I am mistaking the gem call in the file, how should I name it?
Thanks

Browser back button

Hello! There is an issue in UX by using this plugin. Every time by clicking options buttons and viewing variants the address bar gets new hash, that adds to regular URL of the product page. And if user wants to go back to products categories page after choosing option types and clicks BACK in browser, it's figured out, that it's impossible doing by 1 click. The one way to get back is to click on BACK button so many times, as many times the user clicked on option types buttons.

The plugin is perfect actually, but this inconvenience disturbs to enjoy it.

compatibility spree-2-3

Hi, do you think your beta is strong enough to be used in prod ? (I mean no critical issues)

Can't get 2.4 to run with spree_variant_options

Hi,

I've had a go at putting this into my gemfile which looks like this

gem 'spree', github: 'spree/spree', branch: '2-4-stable'
gem 'spree_gateway', :git => 'https://github.com/spree/spree_gateway.git', :branch => '2-4-stable'
gem 'spree_auth_devise', :git => 'https://github.com/spree/spree_auth_devise.git', :branch => '2-4-stable'
# gem 'spree_i18n', github: 'spree-contrib/spree_i18n', branch: '2-4-stable'
gem 'spree_variant_options', :github => 'AgilTec/spree_variant_options', :branch => '2-4-stable'

which bundles fine. However, when running the server in dev with "rails s", I get the following error:

controllers/spree/products_controller_decorator.rb:1:in <top (required)>': private methodinclude' called for Spree::ProductsController:Class (NoMethodError)

I've deleted the Gemfile.lock and updated all gems including --system, but I'm afraid I'm not getting anywhere. My site has been updated from an older version of Spree (2.1 rings a bell).

Many thanks - this gem is exactly what I've been looking for!!!

Regards,
Gareth

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.