Table of Contents

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 Dynamicweb.Ecommerce.Products;
using Dynamicweb.Ecommerce.Stocks;
using Dynamicweb.Extensibility.Notifications;
using Dynamicweb.Mailing;
using StatusChangedArgs = Dynamicweb.Ecommerce.Notifications.Ecommerce.Stock.StatusChangedArgs;

namespace Dynamicweb.Ecommerce.Examples.Notifications
{
    /// <summary>
    /// Subscribing on StatusChanged event
    /// </summary>
    [Subscribe(Dynamicweb.Ecommerce.Notifications.Ecommerce.Stock.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 == null || !(args is StatusChangedArgs))
                return;
            var tmpArgs = (StatusChangedArgs)args;
            Product product = tmpArgs.Product;
            StockStatus oldStockStatus = tmpArgs.OldStockStatus;
            StockStatus newStockStatus = tmpArgs.NewStockStatus;

            //send e-mail
            string emailBody = string.Format("ProductID:{0}&lt;br/&gt;Old stock status:{1}&lt;br/&gt;New stock status:{2}", product.Id, oldStockStatus.GetText(product.LanguageId), newStockStatus.GetText(product.LanguageId));
            //
            EmailHandler.Send(null, 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

string

Examples

using Dynamicweb.Ecommerce.Products;
using Dynamicweb.Ecommerce.Stocks;
using Dynamicweb.Extensibility.Notifications;
using Dynamicweb.Mailing;
using StatusChangedArgs = Dynamicweb.Ecommerce.Notifications.Ecommerce.Stock.StatusChangedArgs;

namespace Dynamicweb.Ecommerce.Examples.Notifications
{
    /// <summary>
    /// Subscribing on StatusChanged event
    /// </summary>
    [Subscribe(Dynamicweb.Ecommerce.Notifications.Ecommerce.Stock.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 == null || !(args is StatusChangedArgs))
                return;
            var tmpArgs = (StatusChangedArgs)args;
            Product product = tmpArgs.Product;
            StockStatus oldStockStatus = tmpArgs.OldStockStatus;
            StockStatus newStockStatus = tmpArgs.NewStockStatus;

            //send e-mail
            string emailBody = string.Format("ProductID:{0}&lt;br/&gt;Old stock status:{1}&lt;br/&gt;New stock status:{2}", product.Id, oldStockStatus.GetText(product.LanguageId), newStockStatus.GetText(product.LanguageId));
            //
            EmailHandler.Send(null, true);
        }
    }
}
To top