ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Apply coupon code and Track Affiliate while shopping


#1

Use case:
There are resellers/other site which generates leads for your ERPNEXT e-commerce website products/items/. When the user comes from other site to erpnext site for purchase, you should have the ability
(a) to know from which affiliate /sales partner he is coming (may be to give them exact commission or to analyse their performance) i.e. referral code
(b)Give user discount (based on Pricing Rule) on overall purchase i.e. Coupon code

Design :

[A] Sales Partner with unique referral code
Each Sales Partner can have unique referral code as below

[B] Coupon Code Doctype
Coupon Code form will look as below ,Coupon Code will be unique . It will be linked with Pricing Rule for discount calculation based on defined conditions.
Coupon Used count will update , when user will place order on shopping portal.

[C] Shopping cart flow
Potential customer will land to the website with URL as below
http://sellcc.erpnext.com/products/chair?sp=speed&cc=SAVE30
system will save the URL parameters in browser cookie , which will expire in 30 mins ( which sounds a good amount of shopping engagement time on the site).

After adding items to the cart, the cart will look as below

The Coupon Code custom field will be added as below to capture & apply the relevant discount to the user, while the sales partner code will remain hidden (though visible below) .
System will fetch the sales partner , mapped to the (unique) referral code, and will set in the Quotation ( Sales Partner – custom field) & Sales Order ( Sales Partner- field).

Shopping cart view

[D] Impact on Quotation and Sales Order when order is placed
At present , whenever potential customer , clicks on “”Add to Cart” button, in background ERPNext prepares Quotation and updates its line items based on various item additions.

On click of the “Place Order” button , Sales Order gets generated with the relevant details.

So the quotation and sales order with sales partner ( Print Hide) and coupon code information will look as below.

Quotation form
Edit : Pricing Rule is made to overwrite Price List / define discount percentage, based on defined criteria.
Discount section is to provide “Additional Discount” - as the section heading suggest, the "Additional Discount Percentage/ Additional Discount Amount (USD) fields will not be updated

Quotation Line Item will carry the discount information based on pricing rule

Sales Order on Shopping Cart Portal will look as below

Sales Order Form will have the Coupon Code Information

Edit : Pricing Rule is made to overwrite Price List / define discount percentage, based on defined criteria. Hence the Discount Precentage & Discount Amount field will not get updated.

Sales Order Item will carry the discount information based on pricing rule

Sales Order form will have the sales partner information

Looking forward for co-operation on getting this feature merged asap.

Since there are no defined module leaders for shopping cart, I would request the reviewer team (, @rmehta,@nabin ) to review it and give us approval on the same.

At the same time we would request to community members to give us suggestion only by keeping in mind the scope defined in the use case,.
If there are features above the scope request you to raise a different PR with reference to this one.
We wish to merge this within 2 weeks!

Below are the links of earlier discussion on same topic
Issue/ PR : https://github.com/frappe/erpnext/pull/12559
Discuss Post : How to get affiliate link and URL

Edit : After further analysis, in Quotation, SO.SI form .
Pricing Rule is made to overwrite Price List / define discount percentage, based on defined criteria.
Discount section is to provide “Additional Discount” - as the section heading suggest, so "Additional Discount Percentage/ Additional Discount Amount (USD) fields will not get updated through shopping cart .

Quotation Item and Sales Order Item will carry the discount information based on pricing rule.

Hence changed the screenshots of_

  1. Quotation Form
  2. Sales Order Form
  3. Sales Order on Webportal

Added two new screenshots of

  1. Quotation Item
  2. Sales Order Item

#2

Looks okay, but UI for “Apply Referral Code” looks bad.

Also this will have to be contributed to develop branch


#3

Hello, this really is somewhat “obvious” idea, meaning this should really be in the system. :wink:

What comes into my mind is that the ERPNext shopping cart needs an overall drastic development and that means that this type of stuff should be thought in a way that it won’t need to be totally re-designed after the shopping cart module changes otherwise (of course some adjustments are needed in any case).

I would understand @rmehta comment in such way that first this PR must be contributed into the develop branch and then if all ok, tested, it can be brought to the master branch. Let me know Rushabh if this is what you meant.

What comes to the UI suggestion, I do agree that the above sample doesn’t look the best option yet, but it is no problem to make it follow the basic look and feel of ERPNext, so I assume that as a minor thing to fix.


#4

Develop to master can be a long route though! At this point there is no ETA


#5

We are done with
[1] Code PR
[2] It has test case. find video of same
[3] You can do hands on. Test server
[4] Documentation PR for
Coupon Code
Sales Partner Referral Code

We are awaiting Reviewer’s approval on PR.


#6

We would like to invite if anyone would wish to give a hands-on to the feature.

Basic Steps for customer (end-user) testing

  1. Click on the link
  2. Check the price and add the item to the cart and use the customer login mentioned below
3. View Cart

  1. Apply Coupon Code and check the discounted price
  2. Click on “Place Order” button to view final order price details

Customer user :
donald@trump.com
hello@2020

Test Server Instance Details

To Test the feature in action
Test Instance URL

Test Data :

Items [URL] Rate Coupon Code Discount Grand Total
1)Golden Ring 750 SAVE5 (5%) 37.50 712.50
2)Chair 500 – 0 500

Desk User :
desk@user.com
hello@2020

Other Important Data Links

Coupon Code
Pricing Rule
Shopping Cart Settings
Sales Partner

Steps to configure Coupon Code Feature

Ensure Shopping Cart Settings > Apply Coupon Code is enabled.

CCShoppingCartSettings

  1. Create Item
2) Create Pricing Rule for Item in step 1 - (Coupon Code Based = true

3) Create Coupon Code , link it with Pricing Rule of Step 2

4) Add Item in Shopping Cart and view cart

  1. Apply Coupon Code and check the price

#7

This is a critical feature for online shopping. Will this be merged to v12 or V11 branch? Will appreciate a clarification.


#8

@zerodiscount, we have submitted the PR for review. It is for v12 develop branch.
PR - https://github.com/frappe/erpnext/pull/17117

This critical feature for online shopping is requested and sponsored by @MichaelPinkowski
& @Steve_Simonson
Big thanks! to them for giving back to the community


#9

Jignesh - Thanks all for your work to develop and to Michael and Steve for sponsoring this feature. Have question - when implemented - will it be possible to apply a coupon automatically? So for example - list price is MRP and then a SALE25 coupon needs applied for all visitors - showing the discounted price with say 25% off ? What price will show before adding to cart? MRP or net price after coupon? And in Cart will show according to your PR - listing both MRP and discount amount? Thanks for the clarification.

Nailesh