Developer forum

Forum » Ecommerce - Standard features » Event fired when creat a new order

Event fired when creat a new order

Judy Zhang
Reply
Hi DW,

We have made a event hanlder method which subscribes to these 4 events

"ProductAdded"
"ProductRemoved"
"QuantityeIncreased"
"QuantityRemoved"

But when we add the first product to Cart, it seems like that the method doesn't get executed.
And I tried to subscribe to the CartCreated event, but this event doesn't have orderline as event argument. We cannot calculate discount without a reference to orderline.

I want to know if it is beacuse when a new order is created, "ProductAdded" event is not fired?
If not, which even should we subscribe to?


Regards
Judy



Replies

 
Vladimir
Reply
Hi Judi!
What version of Dynamicweb and cart do you use?
I check with such hadler in DW 8.1.0.0 and CartV2:
    [Dynamicweb.Extensibility.Subscribe(Dynamicweb.Notifications.eCommerce.Cart.Line.Added),
    Dynamicweb.Extensibility.Subscribe(Dynamicweb.Notifications.eCommerce.Cart.Line.Increased)]
    public class EcomCartLineIncreasedObserver : Dynamicweb.Extensibility.NotificationSubscriber
    {
        public override void OnNotify(string notification, Dynamicweb.Extensibility.NotificationArgs args)
        {
            if (args == null || !(args is Dynamicweb.Notifications.eCommerce.Cart.Line.IncreasedArgs))
                return;

            Dynamicweb.Notifications.eCommerce.Cart.Line.IncreasedArgs item = (Dynamicweb.Notifications.eCommerce.Cart.Line.IncreasedArgs)args;

            //TODO: Add code here
        }
    }
It is work fine

Best regards,
Vladimir

ps: perhaps SalesDiscountProvider will more suitable for you?



 

You must be logged in to post in the forum