Class Ecommerce.Stock
- Namespace
- Dynamicweb.Ecommerce.Notifications
- Assembly
- Dynamicweb.Ecommerce.dll
Provides notification names for product stocks.
public sealed class Ecommerce.Stock
- Inheritance
-
Ecommerce.Stock
- Inherited Members
Examples
using System.Net.Mail;
using Dynamicweb.Ecommerce.Products;
using Dynamicweb.Ecommerce.Stocks;
using Dynamicweb.Extensibility.Notifications;
using Dynamicweb.Mailing;
using static Dynamicweb.Ecommerce.Notifications.Ecommerce.Stock;
namespace Dynamicweb.Ecommerce.Examples.Notifications;
/// <summary>
/// Subscribing on StatusChanged event
/// </summary>
[Subscribe(StatusChanged)]
public class EcomStatusChangedObserver : NotificationSubscriber
{
/// <summary>
/// Occurs after the stock status has been changed.
/// </summary>
/// <param name="notification"></param>
/// <param name="args"></param>
public override void OnNotify(string notification, NotificationArgs args)
{
if (args is not StatusChangedArgs tmpArgs)
return;
Product product = tmpArgs.Product;
StockStatus oldStockStatus = tmpArgs.OldStockStatus;
StockStatus newStockStatus = tmpArgs.NewStockStatus;
//send e-mail
using var mail = new MailMessage();
mail.Subject = "MESSAGE SUBJECT";
mail.IsBodyHtml = true;
mail.Body = $"ProductID:{product.Id}<br/>Old stock status:{oldStockStatus.GetText(product.LanguageId)}<br/>New stock status:{newStockStatus.GetText(product.LanguageId)}";
mail.From = EmailHandler.SystemMailFrom();
mail.To.Add("test@mail.com");
EmailHandler.Send(mail, true);
}
}
Remarks
The passed NotificationArgs is Ecommerce.Stock.StatusChangedArgs
Fields
StatusChanged
Occurs after the stock status has been changed.
public const string StatusChanged = "DWN_ECOM_STOCK_STATUS_CHANGED"
Field Value
Examples
using System.Net.Mail;
using Dynamicweb.Ecommerce.Products;
using Dynamicweb.Ecommerce.Stocks;
using Dynamicweb.Extensibility.Notifications;
using Dynamicweb.Mailing;
using static Dynamicweb.Ecommerce.Notifications.Ecommerce.Stock;
namespace Dynamicweb.Ecommerce.Examples.Notifications;
/// <summary>
/// Subscribing on StatusChanged event
/// </summary>
[Subscribe(StatusChanged)]
public class EcomStatusChangedObserver : NotificationSubscriber
{
/// <summary>
/// Occurs after the stock status has been changed.
/// </summary>
/// <param name="notification"></param>
/// <param name="args"></param>
public override void OnNotify(string notification, NotificationArgs args)
{
if (args is not StatusChangedArgs tmpArgs)
return;
Product product = tmpArgs.Product;
StockStatus oldStockStatus = tmpArgs.OldStockStatus;
StockStatus newStockStatus = tmpArgs.NewStockStatus;
//send e-mail
using var mail = new MailMessage();
mail.Subject = "MESSAGE SUBJECT";
mail.IsBodyHtml = true;
mail.Body = $"ProductID:{product.Id}<br/>Old stock status:{oldStockStatus.GetText(product.LanguageId)}<br/>New stock status:{newStockStatus.GetText(product.LanguageId)}";
mail.From = EmailHandler.SystemMailFrom();
mail.To.Add("test@mail.com");
EmailHandler.Send(mail, true);
}
}
StockLocationsCleared
Occurs after the cache for stock location(s) have been cleared.
public const string StockLocationsCleared = "DWN_ECOM_STOCK_LOCATIONS_AfterClearCache"
Field Value
Remarks
* If Ids contain no elements, the entire cache was cleared.
* If Ids contain one or more elements, only the cache for those stock locations was cleared.
StockLocationsDeleted
Occurs after one or more stock locations have been deleted.
public const string StockLocationsDeleted = "DWN_ECOM_STOCK_LOCATIONS_AfterDelete"