GithubHelp home page GithubHelp logo

kbuckler / solidus_related_products Goto Github PK

View Code? Open in Web Editor NEW

This project forked from solidusio-contrib/solidus_related_products

0.0 1.0 0.0 412 KB

:fork_and_knife: Related products extension for Solidus

License: BSD 3-Clause "New" or "Revised" License

Ruby 84.43% JavaScript 0.86% HTML 12.56% CoffeeScript 2.02% Shell 0.13%

solidus_related_products's Introduction

Related Products

CircleCI Gem License

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 or via Related Products section on the edit variant UI.

Installation

Add to Gemfile:

gem 'solidus_related_products'

Run:

$ bundle install
$ bundle exec rails g solidus_related_products:install

Possible uses

  • Accessories
  • Cross Sells
  • Up Sells
  • Compatible Products
  • Replacement Products
  • Warranty & Support Products

Relation Types

You can create four different RelationTypes:

Applies From Applies To Bi-Directional available
Spree::Product Spree::Product Yes
Spree::Product Spree::Variant No
Spree::Variant Spree::Product No
Spree::Variant Spree::Variant Yes

Bi-Directional You can optionally set the bi-directional flag (if available) to automatically create the inverse relation, the flag can be set only on the type creation and can't be changed later, this is needed to avoid unpredictable behavior in the case that the flag is changed. Keep in mind that if you remove one side of the relation, also the other hand will be removed, the same way happens for the description. The discounts are disabled for Bi-Directional by setting the discount amount to be only zero, this is needed because it's not clear how this feature should behave in this case.

The following examples use a Spree::Product -> Spree::Product relation type.

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_from: 'Spree::Product', 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).

Contributing

See corresponding guidelines


Copyright (c) 2010-2015 Brian Quinn and contributors, released under the New BSD License

solidus_related_products's People

Contributors

jhawthorn avatar futhr avatar kennyadsl avatar jdutil avatar aldesantis avatar bdq avatar graygilmore avatar christianrimondi avatar alessiorocco avatar aitbw avatar radar avatar brchristian avatar jsqu99 avatar lbrapid avatar ajjahn avatar schof avatar vassalloandrea avatar blocknotes avatar alepore avatar danielepalombo avatar nishant-cyro avatar citrus avatar patrickmcelwee avatar florianguenther avatar geekoncoffee avatar damianlegawiec avatar gudata avatar chischaschos avatar maokomioko avatar rainerdema avatar

Watchers

James Cloos avatar

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.