130 likes | 286 Views
E-commerce Scenarios. Partners’ Webinar 10/25/2012 Karol Jarkovsky Solution Architect karolj@kentico.com. Agenda. Customization Model Overview B undling Product with Custom Data Customization Scenarios DEMO: Flexible shipping, DEMO: Multiple pricing level per SKU
E N D
E-commerce Scenarios Partners’ Webinar 10/25/2012 Karol Jarkovsky Solution Architect karolj@kentico.com
Agenda • Customization Model Overview • Bundling Product with Custom Data • Customization Scenarios • DEMO: Flexible shipping, • DEMO: Multiple pricing level per SKU • DEMO: Shared membership
Customization Model • Full details available as blogand video on DevNet, and in the Developer’s Guide, <XYZ>InfoProvider.cs UserInfoProvider.cs public static ProviderObject public static ProviderObject public static GetUserInfo(int userId) public static <methodName>() protected virtual GetUserInfoInternal (int userId) protected virtual <methodName>Internal()
Custom Data Bundling: CustomData • COM_OrderItem [Table] OrderItemCustomData[Column] • COM_Order [Table] OrderCustomData[Column] • COM_ShoppingCartSKU [Table] CartItemCustomData[Column] <customdata> <mycustomvalue3>CME Group</mycustomvalue3> <mycustomvalue2>25.55</mycustomvalue2> <mycustomvalue4>35.47</mycustomvalue4> <mycustomvalue1>Sample value 1</mycustomvalue1> </customdata> <customdata> <mycustomvalue1>CME Group</mycustomvalue1> <mycustomvalue2>Sample value 1</mycustomvalue2> </customdata> <customdata> <mycustomvalue3>CME Group</mycustomvalue3> <mycustomvalue2>25.55</mycustomvalue2> <mycustomvalue4>35.47</mycustomvalue4> <mycustomvalue1>Sample value 1</mycustomvalue1> </customdata> Database • COM_ShoppingCart [Table] ShoppingCartCustomData[Column] <customdata> <mycustomvalue1>CME Group</mycustomvalue1> <mycustomvalue2>Sample value 1</mycustomvalue2> </customdata> API protectedoverrideShoppingCartItemInfo AddShoppingCartItemInternal(ShoppingCartInfo cart, ShoppingCartItemParameters itemParams) { // Add item to the shopping cart ShoppingCartItemInfo item = base.AddShoppingCartItemInternal(cart, itemParams); if (item != null) { // Accepts simple data values item.CartItemCustomData["MyCustomValue1"] = "Sample value 1"; item.CartItemCustomData["MyCustomValue2"] = 25.55; // int myVal= (int)item.CartItemCustomData["MyCustomValue2"]; // Hashtable myValues = item.CartItemCustomData.ConvertToHashtable(); } return item; }
Custom Data Bundling: RelatedData API // Registering for event fired when lazy-loaded RelatedData property is accessed SKUInfo.TYPEINFOSKU.OnLoadRelatedData += newTypeInfo.ObjectLoadRelatedDataEventHandler(TYPEINFOSKU_OnLoadRelatedData); protectedobject TYPEINFOSKU_OnLoadRelatedData(BaseInfo infoObj) { CustomDataContainerresult = null; SKUInfoprod = (infoObj asSKUInfo); if(prod != null) { result = newCustomDataContainer() { MarketPriceSourceName = "CME Group", MarketPriceValue = 35.47 }; } returnresult; } ///<summary> /// Summary description for CustomDataContainer ///</summary> publicclassCustomDataContainer : IDataContainer { // Implementation of IDataContainer members } protectedoverrideShoppingCartItemInfo AddShoppingCartItemInternal(ShoppingCartInfo cart, ShoppingCartItemParameters itemParams) { // Add item to the shopping cart ShoppingCartItemInfoitem = base.AddShoppingCartItemInternal(cart, itemParams); if(item != null) { // Accepts simple data values item.CartItemCustomData["MyCustomValue3"] = item.SKU.GetValue("MarketPriceSourceName"); item.CartItemCustomData["MyCustomValue4"] = item.SKU.GetValue("MarketPriceValue"); } returnitem; }
Scenarios DEMO: Flexible shipping • Scenario • Instead of flat shipping fee specified for shipping option you want to apply different shipping costs per product (e.g. based on dimensions), • Total shipping costs should be discounted or completely waved if certain numbers of products are added to the cart
DEMO: Flexible shipping API • CMS.Ecommerce.ShippingOptionInfoProvider • ApplyShippingFreeLimit[Internal](doubleshipping, double totalPrice, • doublesiteStoreFreeLimit) • Evaluates store free-shipping limit against total price and return shipping costs, • CalculateShipping[Internal](ShoppingCartInfocartObj) • Evaluates total shipping costs for whole cart (all items), • To implement custom shipping cost calculation you need to override this method, • CalculateShippingTax[Internal](ShoppingCartInfocartObj) • Evaluates taxes for total shipping costs, • IsShippingNeeded[Internal](ShoppingCartInfocart) • Indicates whether the shipping is necessary for given shopping cart, • Returns TRUE if any of the products in the cart requires shipping (has Needs shipping setting enabled), • Bundled items are not included within evaluation.
Scenarios DEMO: Multiple pricing level per SKU • Scenario • Instead of single (flat) price you want to display price customized for current visitor, • Each product will have two price variants – variant A representing full price and variant B representing special offer price for new customers, • New visitor is unknown customer, • Also, if visitor is exiting customer you want to add 10% discount on any product they already purchased (in last 30 days)
DEMO: Multiple pricing level per SKU API • CMS.Ecommerce.SKUInfoProvider • CalculateSKUDiscount[Internal](SKUInfosku, ShoppingCartInfo cart, IItemDiscount discount, • doublepriceAfterDiscount) • Calculates discount for given SKU reflecting given discount information, • Performs actual calculation using price with any previous discounts applied, • GetSKUDiscounts[Internal](SKUInfosku, ShoppingCartInfo cart, bool forCart) • Returns list of discounts that are then applied to the base price in order they are included in the list, • Method that is performing calculation is CalculateSKUDiscount[Internal]() above, • GetSKUPrice[Internal](SKUInfosku, ShoppingCartInfo cart) • GetSKUPrice[Internal](SKUInfo sku, ShoppingCartInfo cart, string column) • GetSKUPrice[Internal](SKUInfosku, ShoppingCartInfo cart, bool discounts, bool taxes, bool forCart, string column) • Returns price for given product, • Customizations should be done by overwriting highlighted (bold) override as both methods left are internally calling this method,
Scenarios DEMO: Shared membership • Scenario • You want to assign purchased membership for all users coming from the same company/organization, • In other words instead of single-user membership product you want to allow buying shared membership
DEMO: Shared membership API • CMS.Ecommerce.OrderInfoProvider • CreateEmailMacroResolver[Internal](ShoppingCartInfocartObj) • CMS.Ecommerce.ShoppingCartInfoProvider.GetShoppingCartResolver[Internal](ShoppingCartInfocart, • boolspecialMacros) • CreateEmailMacroResolver[Internal]() is called only from OrderInfoProvider.SendEmailNotification[Internal]() • If you want to add resolver data available across whole E-commerce module (not just e-mail templates) you need to customize CMS.Ecommerce.ShoppingCartInfoProvider.GetShoppingCartResolver[Internal](), • CreateEmailMacroResolver[Internal]() is calling this method internally to get base resolver, • ProcessOrderIsPaidChangeInternal(OrderInfo oi) • Raised when order is paid status changes (automatically or manually from the UI) , • Handles alternative product types (e-product, membership) and sends out e-mail notifications, • Modify if you want to send additional notifications or so, however e-product processing is customized through separate methods (below), • ProcessMembership[Internal](OrderInfooi, OrderItemInfo oii, SKUInfo skui, UserInfo ui, • DateTimenow) • ProcessEProduct[Internal](OrderInfooi, OrderItemInfo oii, SKUInfo skui, DateTime now) • Called from ProcessOrderIsPaidChange[Internal]() based on product type,
General THANK YOU!