Page 1 of 1

Promotions and offers: discount per customer

Posted: Fri Mar 22, 2013 11:08 am
by tvinke
Hi,

We're looking into using Broadleaf as our e-commerce solution for a new webshop. We're going to have a specific way of importing and using already existing data from another ERP system and I could use some pointers as to how to setup Broadleaf.

The idea is we regularly import 2 types of data through CSV into Broadleaf.

Products.csv - all products (incl. the categories they're in)

Code: Select all

artid, group, description, discountgroup, price
1, Men's wear,T-Shirt, 1002, 14.99
2, General,Baseball hat, 1002, 7.99


CustomerDiscounts.csv - customers and their discounts for a certain discountgroup
custid, discountgroup, percentage

Code: Select all

5,1001,0
5,1002,10
5,1003,20
5,1004,30
6,1001,1
6,1002,11
6,1003,21
6,1004,31


What we want is that if we know customer 5 is logged in, for the T-Shirt (discountgroup 1002) he gets 10 percentage discount on that article. Customer 6 for that same T-Shirt would get 11 percent off.

We expect we can import the products perfectly into the catalog, but I'm looking into how to import our CustomerDiscounts.csv into the existing Promotions/Offer system to get a specific discount on an article for a specific customer.

As I see it in the demo admin application we need to generate for each line in the CustomerDiscounts.csv an offer for each customer/discountgroep-combination with:
- type: Order Item
- discount type: percent off
- discount value: <percentage from the CSV>
- Customer Qualification / Customer Selection Rule: Customer Id equals <custid from CSV>
- Item Qualification / Item Selection Rule: <something which we can match on item's discount group>

This would lead to a lot of offerings - which probably will also have to have a unique name like "Customer-<Id>-<Discountgroup>".

Questions:
- I also don't know where to store my discountgroup near an item (which is not the same as the category the item resides in).
- If we were able to store a discountgroup near an item, of are there any other extension points available? E.g. to dynamically get a percentage from the offering (which looks up the percentage based on customer and discountgroup)?

Re: Promotions and offers: discount per customer

Posted: Sun Mar 24, 2013 3:44 pm
by bpolster
Your approach would likely work but for large numbers of discounts performance could be an issue.

It's a difficult problem to solve efficiently without all the facts. The offer system is fairly complex and it might be wise to get some outside help especially if you are concerned about how well your solution will scale under load.

That being said, the first approach that comes to mind for me is to customize the system to more closely match your domain:
[*] Extend Product to have a discountGroup(String value)
[*] Create a new entity CustomerDiscountGroup (With customerId, discountGroup, percentage)
[*] Extend Customer to have a List of CustomerDiscountGroups
[*] Extend Offer to have a DiscountGroupBasedOffer (this offer type would have a discountGroup field AND derive its amount from the current customer being processed). *Hint: Assuming a typical implementation, you can leverage CustomerState.getCustomer() from within your DiscountGroupBasedOffer's getAmount() method.

This approach would perform well assuming that you don't have tons of customer groups. You would likely need to optimize further if the number of discount groups you have is more than 100.

Re: Promotions and offers: discount per customer

Posted: Mon Mar 25, 2013 3:19 am
by tvinke
Brian, thank you for your help!

A related question for this setup: is this kind of offer (and it's calculation) only triggered in the basket/checkout, or can we already show the discount (percentage) on the product(detail)page itself?