Spree Related Products (Spree 5.3)
This is a fork of the spree-contrib/spree_related_products gem, updated for compatibility with Spree 5.3.
spree_related_products provides a flexible way to define different types of relationships between your products in a Spree Commerce store. You can configure relationships via the admin panel and manage related products within the Related Products tab of the product edit UI.
Features
- Define different types of product relationships
- Manage relationships via the Spree admin panel
- Supports various use cases like upsells, cross-sells, accessories, and replacements
- Optionally apply discounts to related products
Use Cases
- Accessories
- Cross Sells
- Up Sells
- Compatible Products
- Replacement Products
- Warranty & Support Products
Relation Types
You can define a RelationType and access related products dynamically:
rt = Spree::RelationType.create(name: 'Accessories', applies_to: 'Spree::Product')
product = Spree::Product.last
product.accessories # => []
To check if a relation type exists for a product:
product.('accessories') # => true
if product.('accessories')
# Display an accessories box..
end
To access all related products:
product.relations # => []
Discounts on Related Products
You can optionally specify a discount that applies when customers purchase both related products.
To enable automatic discounts, create a promotion without a code and add an action of type RelatedProductDiscount.
Installation
- Add this gem to your
Gemfile:
gem 'spree_related_products', github: 'be-agile/ba_spree_related_products'
- Install the gem using Bundler:
```ruby
bundle install
```
- Copy and run migrations:
```ruby
bundle exec rails g spree_related_products:install
```
- Restart your server:
```sh
rails server
```
License
This extension is available as open source under the terms of either:
Credits
Originally created by Vinsol. Fork maintained by be agile Co., Ltd..