Dynamicweb.Notifications Namespace > eCommerce.Cart Class : Created Field |
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Dynamicweb.Examples.CSharp.Notifications.eCommerce { /// <summary> /// Subscribing on Cart.Created event /// </summary> [Dynamicweb.Extensibility.Subscribe(Dynamicweb.Notifications.eCommerce.Cart.Created)] public class EcomCartCreatedObserver : Dynamicweb.Extensibility.NotificationSubscriber { /// <summary> /// This notification is thrown every time a cart is created. The notification appears when user adds first product to the cart. /// </summary> /// <param name="notification"></param> /// <param name="args"></param> public override void OnNotify(string notification, Dynamicweb.Extensibility.NotificationArgs args) { if (args == null || !(args is Dynamicweb.Notifications.eCommerce.Cart.CreatedArgs)) return; Dynamicweb.Notifications.eCommerce.Cart.CreatedArgs cArgs = (Dynamicweb.Notifications.eCommerce.Cart.CreatedArgs)args; Dynamicweb.eCommerce.Shops.ShopCollection shops = Dynamicweb.eCommerce.Shops.Shop.getShops(); if (shops == null || shops.Count == 0) return; cArgs.Order.ShopID = shops[0].ID; cArgs.Order.Save(); } } }
Imports Dynamicweb Namespace Dynamicweb.Examples.Vb.Notifications.eCommerce <Global.Dynamicweb.Extensibility.Subscribe(Global.Dynamicweb.Notifications.eCommerce.Cart.Created)> _ Public Class EcomCartCreatedObserver Inherits Global.Dynamicweb.Extensibility.NotificationSubscriber Public Overrides Sub OnNotify(ByVal notification As String, ByVal args As Global.Dynamicweb.Extensibility.NotificationArgs) If args Is Nothing OrElse Not (TypeOf args Is Global.Dynamicweb.Notifications.eCommerce.Cart.CreatedArgs) Then Return End If Dim cArgs As Global.Dynamicweb.Notifications.eCommerce.Cart.CreatedArgs = DirectCast(args, Global.Dynamicweb.Notifications.eCommerce.Cart.CreatedArgs) 'TODO: Add code here End Sub End Class End Namespace
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2