What is Spree Affiliate?

Spree Reffiliate is a spree extension that provides the functionality of user referrals and affiliate features to your spree store.

A unique link is generated for users which is shareable to friends and once users purchase a product via that path, then affiliate gain benefits.

Affiliate users are users who earn commission while placing an order or user registrations on their affiliate links sharing.

Features:

  1. A specific role for an affiliate user who gets a commission as per the commission rules created.
  2. Affiliates get the information about the commissions received in the account panel.
  3. Referral codes are generated for users, used to refer to other users.
  4. Users can see the number of referred users and their details in their account panel.

Installation:

  1. Add “spree_reffiliate” to your Gemfile.
    gem 'spree_reffiliate', github: 'vinsol-spree-contrib/spree_reffiliate'
  2. Install the dependencies using:
    bundle install
  3. Run the installation generator:
    bundle exec rails g spree_reffiliate:install
  4. If you already have users in your database, then generate the referral codes for the existing users using the following code:
    bundle exec rake reffiliate:generate
  5. Open rails console and create commission rules for User Registration and Order placement as shown below:
    Spree::CommissionRule.find_or_create_by(name:Spree::CommissionRule::USER_R
    EGISTRATION, fixed_commission: true)

    Spree::CommissionRule.find_or_create_by(name:Spree::CommissionRule::ORDER_
    PLACEMENT, fixed_commission: false)

Changes in View:

  1. Login as admin
  2. Following links will be available in the side menu:

a. Configurations > Affiliates
b. Configurations > Referrals

Configurations

 3. If you visit Configurations > Affiliates, you will see,

configurations affiliates

 4. If you visit Configurations > Referrals, you will see,
Here, in the below image, these configurations are global settings to award the user credits as store credits on referrals and provide benefits.

Referral settings

Implementation: Basically, there are 2 flows:

  1. Affiliation: It works as a third party and gets a commission on user registration and order placement.
  2. Referrals: Users get store credits in their account by sharing the unique codes generated to their friends and get benefits.

Affiliation Flow:

  • Admin end ( Backend )
  1. Login as admin
  2. Create an affiliate user by visiting the link Configurations > Affiliates > Add New Affiliate:
  • Path: A custom path for affiliate users which is shareable to any user to earn benefits as per the commission rules defined.
  • Commission Rules:
    1. Here, we created the commission rules above for User Registration and Order Placement.
    2. The affiliate user will get benefits on every user registration and order placement by using the affiliate link as per the rules defined.
    3. The user registration rule should have some amount.
    4. The order placement rule should have value in percentage (%).

Note:  The rules defined are applied to every affiliate user and can be customized as per the affiliate’s requirement.

listing affiliates
new affiliates
  • After successful creation, the affiliate user will be notified using an email with the activation link to activate the affiliate account.
 activation link instruction
  • Affiliate side

Hit the link provided in the email, and you will be redirected to the edit password page for affiliate users.

 affiliate users creation

Fill in the form with the password and confirmation password, and you will be logged in as an affiliate user in the application.

affiliate user details creation

The affiliate link is shared with other users to gain benefits.

If there is a partial while creating an affiliate, then it will redirect to the home page embedded with the specified partial. Otherwise, it will be redirected to the home page.

Partial should be available at app/views/spree/affiliates path for customizations.

Affiliate users share their affiliate link available in the MyAccount via any media source.

Other users can visit the affiliate’s link, and can purchase products or goods as per their requirements.

  • User side

Hit the affiliate link received.

Hit the affiliate link received

Register the user to the application.

Register the user to the application

Affiliate User for the newly registered user will get a commission on user registration as defined for that respective affiliate.

To check out the commission received, go to MyAccount panel of the affiliate user.

MyAccount panel

After successful registration, if the newly registered user places an order with the standard checkout process, the respective affiliate user will earn commission as per the commission rule defined for order placement.

Commission Transactions can be viewed in MyAccount section for the order placed.

Note: If the user places an order without hitting the affiliate link then the affiliate user will not get the respective commissions.

But after hitting the affiliate link, successful user registration, placing an order with a standard checkout process will provide the commission amount for User Registration and Order Placement to the respective affiliate user.

Registration and Order Placement

Admin can view the affiliates list, their transactions, and commissions received for what type, i.e. User registration/Order Placement.

How will the Commission be Paid to Affiliate Users?

The commission paid to the affiliate will be paid by admin when the commission cycle will complete.

Commission Cycle:

  1. Commission Created for affiliate user has a start date and end date.
  2. Example:
    • Let’s suppose a new user is registered using the affiliate’s link on Dec 19, 2019 ( 19-12-2019 )
    • Commission for that respective affiliate user will be created for user registration.
    • Start date for the commission will be the current month’s start date for when the commission is created.
    • For e.g.: Commission for user registration will be created on 19-12-2019, hence start date = 1-12-2019.
    • End date for the commission will be the current month’s end date for when the commission is created.
    • End date = 31-12-2019.
  3. The commission cycle completes at the end of the current month.
  4. Hence, after the current month’s completion, admin is able to pay the commissions to the affiliate users.

Referrals Flow:

  • Admin can gain benefits by sharing the referral codes to his friends, family, colleagues, etc.
  • Any user can share their referral codes with other end users.
  • Users visiting the referral links get the benefit in the form of store credits configured globally in the admin panel as well as it can be user-specific.
  • Some configurations are required to be done from the admin panel to avail referrals credits.

Global Settings:

  1. Login as admin
  2. Visit the referrals section from Configurations > Referrals:
    1. Store Credits to be awarded are the credits the user would be getting on any referral.
    1. Fill this input with the value with the credits you want to award with.
    2. Check the flag Give Referral Benefits to avail referral credits.
 referral credits

Note: If you don’t want the referral credits to be awarded just uncheck the flag Give Referral Benefits in Configurations > Referrals

If you want to user-specific store credits to be received, then you can always edit as shown below by visiting the Users edit link.

Users edit link

On this user’s successful referrals, referrer (admin@gmail.com) will receive $10 as store credit as it is configured to be user-specific.

How do Referrals Work?

Login as admin.

Visit the account panel.

MyAccount panel of the affiliate user

Admin can share the referral link via any media source to other users.

Users with the referral link of the referred user hit the link in the browser gets benefits on sign up.

Hit the referral link in the browser.

Hit the referral link in the browser

Sign up for a new user.

Sign up for a new user

Admin receives the referral award that can be viewed in the account panel.

Admin can view his referrals details in his account panel.

Admin receives the referral award that can be viewed
admin account panel

When you click on View Details, you will be able to see the number of referred users and credits received on referrals.

referred users View Details

Admin can view the referral store credits in the Users section, as shown below:

referral store credits

Note:  Here, the admin receives the store credits configured in the global settings section above rather than the newly registered user.

But, customizations can be done as per the requirement.

  • A registered user can also share his referral code with his friends, family, colleagues to earn benefits.
    • Registered users can also follow the same procedure as admin referred to other users by following steps 2 to 4 in the above section.

There is no constraint in the number of users to be referred that can up to infinity too!!

Amazing facts:

  • Referral links will be in the form of /r/:referral_code
  • Affiliate links will be in the form of /a/:path

BoTree Technologies is a leading spree commerce development company in Ahmedabad that builds top-notch software and ecommerce solutions to increase business revenue and maximize productivity. Get a FREE CONSULTATION from our CEO.