This extension provides a generic way for you to define different types of relationships between your products, by defining a RelationType for each type of relationship you'd like to maintain.
You can manage RelationTypes via the admin configuration menu, and you can maintain product relationships via Related Products tab on the edit product UI.
- Cross Sells
- Up Sells
- Compatible Products
- Replacement Products
- Warranty & Support Products
When you create a RelationType you can access that set of related products by referencing the relation_type name, see below for an example:
rt = Spree::RelationType.create(name: 'Accessories', applies_to: 'Spree::Product') => #<Spree::RelationType id: 4, name: "Accessories" ...> product = Spree::Product.last => #<Spree::Product id: 1060500592 ...> product.accessories => 
Since respond_to? will not work in this case, you can test whether a relation_type method exists with has_related_products?(method):
product.has_related_products?('accessories') => true if product.has_related_products?('accessories') # Display an accessories box end
You can access all related products regardless of RelationType by:
product.relations => 
Discounts You can optionally specify a discount amount to be applied if a customer purchases both products.
Note: In order for the coupon to be automatically applied, you must create a promotion leaving the code value empty, and adding an Action of type : RelatedProductDiscount (blank codes are required for coupons to be automatically applied).
gem 'spree_related_products', github: 'spree/spree_related_products', branch: 'master'
$ bundle install $ rails g spree_related_products:install
In the spirit of free software, everyone is encouraged to help improve this project.
Here are some ways you can contribute:
- by using prerelease versions
- by reporting bugs
- by suggesting new features
- by writing translations
- by writing or editing documentation
- by writing specifications
- by writing code (no patch is too small: fix typos, add comments, clean up inconsistent whitespace)
- by refactoring code
- by resolving issues
- by reviewing patches
- Fork the repo
- Clone your repo
bundle exec rake test_appto create the test application in
- Make your changes
- Ensure specs pass by running
bundle exec rspec spec
- Submit your pull request