Solidus Dynamic Variants
This gem creates variants in the solidus shop frontend on the fly when the cart is populated. It is meant to be useful for products with many, many options (like Options for lenses), when dynamic variant creation is a better alternative than creating multimillion variant entries for each possible option combination. The Option Values can alter prices as well.
1. Backend Products: Adds a "Dynamic Variants" checkbox to products which makes the variant creation for the product dynamic.
2. Backend Options: Adds a "Surcharge" field to option values which contains optional surcharges for specific options.
3. Frontend Product Detail Screen: Renders Select Boxes for each Option instead of Radio Buttons for each Variant
The process of dynamic variant creation in the frontend works like this:
- Shows all available options as dropdowns in product screen (see above).
- When product is put in cart, the correct variant is created if it doesn't exist yet.
- The variant will have the price of the product plus the surcharges of its selected option values
- Existence of a products variant is checked by options and price (if the price is altered a new variant will be created).
Add solidus_dynamic_variants to your Gemfile:
gem 'solidus_dynamic_variants', github: 'hefan/solidus_dynamic_variants'
Bundle your dependencies and run the installation generator:
bundle bundle exec rails g solidus_dynamic_variants:install
Assumes the customized Variant will be created after ordering (or is digital). This Means: If track inventory is on, the newly created variant will have track_inventory = false.
The newly created variant will have the same SKU like the master variant plus a timestamp.
When you create Orders in the Backend you still need to create variants by hand.
First bundle your dependencies, then run
rake will default to building the dummy app if it does not exist, then it will run specs, and Rubocop static code analysis. The dummy app can be regenerated by using
bundle bundle exec rake
When testing your applications integration with this extension you may use its factories. Simply add this require statement to your spec_helper:
Copyright (c) 2021 stefan hartmann, released under the New BSD License