Commerce Server: Multi-Channel E-tail - Targeting Discounts to 1 Store
Scenario
You need to support multiple e-commerce stores and simply rebrand each store with it's own theming, CSS, etc. while sharing all of the business logic you have written in your business layer. Your stores (www.a.com, www.b.com, www.c.com) all share the same catalog,inventory and checkout. However, you want to give your business users the ability to target discounts to a particular store or select stores.
Solution
Depending on your requirements, you could implement this with 1 CS site and an IIS application per each store. Each application will share the site's resources (profiling, transactions, marketing, catalog, inventory).
In such an implementation, by default any discount you create will appear on all stores. To target particular stores, we just need to do a little extra work.
1. Create a profile definition called StoreTargeting which points to a SQL table called StoreTargeting.
2. Give the StoreTargeting table a StoreID and Description.
3. Populate StoreTargeting table w/ store data.
ID Description
B www.b.com
C www.c.com
4. Open Marketing Manager.
5. Go to “Set Targeting Profiles” and add StoreTargeting as a targeted context.
6. Create Global Expressions for each store.
Name Field Condition Value
www.a.com StoreTargeting.StoreID Is equal to A
www.b.com StoreTargeting.StoreID Is equal to B
www.c.com StoreTargeting.StoreID Is equal to C
7. Create a discount called “www.a.com Only – 10% Off”.
8. Under the eligibility tab, add the “www.a.com” global expression.
9. Create a discount called “www.b.com Only – 20% Off”.
10. Under the eligibility tab, add the “www.b.com” global expression.
11. Create a discount called “www.c.com Only – 30% Off”.
12. Under the eligibility tab, add the “www.c.com” global expression.
13. Add the following to your web.config
<appSettings>
<!—Store # -->
<add key="StoreNumber" value="A"/>
</appSettings>
14. Put this code just prior to the Basket.pcf execution.
// Get the Store # from the web.config
string storeNumber = System.Configuration.ConfigurationManager.AppSettings["StoreNumber"];
// Get the Store Targeting Profile
Profile storeTargetProfile = CommerceContext.Current.ProfileSystem.GetProfile(storeNumber, "StoreTargeting");
// Add the Store Targeting Profile to the pipeline’s profiles collection.
using (PipelineInfo pipeline = new PipelineInfo(“basket”, OrderPipelineType.Basket))
{
pipeline.Profiles.Add("StoreTargeting", storeTargetProfile);
}
// Execute the pipeline
PipelineExecutionResult result = basket.RunPipeline(pipeline);
15. Try out each discount under each IIS application. You will of course need to set the Store # appSetting to the appropriate value. When you access www.a.com, you will receive a 10% off discount but not when you access www.b.com or www.c.com.
Comments and feedback are very much welcome.
Tom
Comments
- Anonymous
February 05, 2007
This is cool stuff! Thanks a lot tom, for sharing this with us. I am trying this out and will let you know how it goes!