Class Ecommerce.Cart.Line
- Namespace
- Dynamicweb.Ecommerce.Notifications
- Assembly
- Dynamicweb.Ecommerce.dll
Provides notification names for Ecommerce cart.
public class Ecommerce.Cart.Line
- Inheritance
-
Ecommerce.Cart.Line
- Inherited Members
Examples
using Dynamicweb;
namespace Dynamicweb.Ecommerce.Examples.Notifications
{
[Dynamicweb.Extensibility.Notifications.Subscribe(Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.Added)]
public class EcomCartLineAddedObserver : Dynamicweb.Extensibility.Notifications.NotificationSubscriber
{
public override void OnNotify(string notification, Dynamicweb.Extensibility.Notifications.NotificationArgs args)
{
if (args == null || !(args is Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.AddedArgs))
return;
Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.AddedArgs added = (Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.AddedArgs)args;
//Add code here
//Dynamicweb.Base.WriteEventLog(string.Format("The cart line (ID:{0}) has been added", added.AddedLine.ID),
// System.Diagnostics.EventLogEntryType.Information);
}
}
}
Remarks
The passed NotificationArgs is Ecommerce.Cart.Line.AddedArgs
Fields
Added
Occurs when the user added product to the cart.
public const string Added = "DWN_ECOM_CART_LINE_ADDED"
Field Value
Examples
using Dynamicweb;
namespace Dynamicweb.Ecommerce.Examples.Notifications
{
[Dynamicweb.Extensibility.Notifications.Subscribe(Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.Added)]
public class EcomCartLineAddedObserver : Dynamicweb.Extensibility.Notifications.NotificationSubscriber
{
public override void OnNotify(string notification, Dynamicweb.Extensibility.Notifications.NotificationArgs args)
{
if (args == null || !(args is Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.AddedArgs))
return;
Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.AddedArgs added = (Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.AddedArgs)args;
//Add code here
//Dynamicweb.Base.WriteEventLog(string.Format("The cart line (ID:{0}) has been added", added.AddedLine.ID),
// System.Diagnostics.EventLogEntryType.Information);
}
}
}
Decreased
Occurs when product was added to the cart and its amount decreased
public const string Decreased = "DWN_ECOM_CART_LINE_DECREASED"
Field Value
Examples
using Dynamicweb;
namespace Dynamicweb.Ecommerce.Examples.Notifications
{
[Dynamicweb.Extensibility.Notifications.Subscribe(Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.Decreased)]
public class EcomCartLineDecreasedObserver : Dynamicweb.Extensibility.Notifications.NotificationSubscriber
{
public override void OnNotify(string notification, Dynamicweb.Extensibility.Notifications.NotificationArgs args)
{
if (args == null || !(args is Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.DecreasedArgs))
return;
Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.DecreasedArgs item = (Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.DecreasedArgs)args;
//Add code here
//if (item.DecreasedLine.Quantity < 2)
//{
// item.DecreasedLine.Quantity = 2;
// item.DecreasedLine.Save();
//}
}
}
}
Increased
Occurs when product was added to the cart and the amount of products in the cart increased
public const string Increased = "DWN_ECOM_CART_LINE_INCREASED"
Field Value
Examples
using Dynamicweb;
namespace Dynamicweb.Ecommerce.Examples.Notifications
{
[Dynamicweb.Extensibility.Notifications.Subscribe(Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.Increased)]
public class EcomCartLineIncreasedObserver : Dynamicweb.Extensibility.Notifications.NotificationSubscriber
{
public override void OnNotify(string notification, Dynamicweb.Extensibility.Notifications.NotificationArgs args)
{
if (args == null || !(args is Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.IncreasedArgs))
return;
Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.IncreasedArgs item = (Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.IncreasedArgs)args;
//Add code here
//if (item.IncreasedLine.Quantity > 5)
//{
// item.IncreasedLine.Quantity = 1;
// item.IncreasedLine.Save();
//}
}
}
}
NotAdded
Occurs when the user tries to ad a product to the cart but it cannot because it is not in stock etc.
public const string NotAdded = "DWN_ECOM_CART_LINE_NOT_ADDED"
Field Value
Removed
Occurs when the user removed product from the cart
public const string Removed = "DWN_ECOM_CART_LINE_REMOVED"
Field Value
Examples
using Dynamicweb;
namespace Dynamicweb.Ecommerce.Examples.Notifications
{
[Dynamicweb.Extensibility.Notifications.Subscribe(Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.Removed)]
public class EcomCartLineRemovedObserver : Dynamicweb.Extensibility.Notifications.NotificationSubscriber
{
public override void OnNotify(string notification, Dynamicweb.Extensibility.Notifications.NotificationArgs args)
{
if (args == null || !(args is Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.RemovedArgs))
return;
Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.RemovedArgs removed = (Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.RemovedArgs)args;
//Add code here
//Dynamicweb.Base.WriteEventLog(string.Format("The cart line (ID:{0}) has been removed", removed.RemovedLine.ID),
// System.Diagnostics.EventLogEntryType.Information);
}
}
}