Developer forum

Forum » Development » Ecom Notification Subscriber issues.

Ecom Notification Subscriber issues.

Rasmus Pedersen
Reply
Why is the code below not working? Am I missing something?
namespace CustomModules.CustomModules.EcomExtension
{
    [Subscribe(Dynamicweb.Notifications.eCommerce.Order.Steps.Completed)]
    public class EcomConfirmationMailExtender: NotificationSubscriber
    {
        public override void OnNotify(string notification, Dynamicweb.Extensibility.NotificationArgs args)
        {
            Base.WriteTextFile("yay", "/files/dummy.txt");
                 }
        }
}


Replies

 
Nicolai Høeg Pedersen
Reply
Are you using cartv1 or cartv2?
 
Rasmus Pedersen
Reply
 V1

I tried all the steps available, nothing is producing a result.
 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer
OK - then it is the correct notification.

But your second argument is a NotificationArg object - cartv1 uses an array of objects:
http://developer.dynamicweb-cms.com/api/extensibility/?Dynamicweb~Dynamicweb.Notifications.eCommerce+Order+Steps~Completed.html

So like this:

[Dynamicweb.Extensibility.Subscribe(Dynamicweb.Notifications.eCommerce.Order.Steps.Completed)]
    public class EcomStepsCompletedObserver : Dynamicweb.Extensibility.NotificationSubscriber
    {
        public override void OnNotify(string notification, object[] args)
        {
            if (args == null || args.Length != 3)
                return;
 
            Dynamicweb.eCommerce.Orders.Order order = (Dynamicweb.eCommerce.Orders.Order)args[0];
            Dynamicweb.Frontend.Extranet extranet = (Dynamicweb.Frontend.Extranet)args[1];
            Dynamicweb.Frontend.PageView pw = (Dynamicweb.Frontend.PageView)args[2];
 
            //Todo: insert code here
        }
    }


Votes for this answer: 0
 
Rasmus Pedersen
Reply

 Still nothing, any other Ideas? or should I go for cartv2 if it is an option?

The solution is on DLLs:
 

Dynamicweb.dll 19.2.3.0


 
Nicolai Høeg Pedersen
Reply
Well - somehow you are doing something wrong.
Where is the DLL with your add-in located? Are you COMPLETELY sure it is placed in the current /Bin folder?

If it is a new solution - YES you should go with Cartv2.

Otherwise - drop a URL and we will have a look.

 
Rasmus Pedersen
Reply

 Turns out it was working.

It is sending a mail as it should, the Base.WriteTextFile() wasn't writing as it should.

thank you

 
Martin Skov Nielsen
Reply
Well - somehow you are doing something wrong.
Where is the DLL with your add-in located? Are you COMPLETELY sure it is placed in the current /Bin folder?

If it is a new solution - YES you should go with Cartv2.

Otherwise - drop a URL and we will have a look.

Well I'm using cart v2 - but I can't get the subscriber to trigger on 
 public override void OnNotify(string notification, 
NotificationArgs argsBase)
but it fires on 
 public override void OnNotify(string notification, 
object[] argsBase)
I thought NotificationArgs was prefered??
 
Nicolai Høeg Pedersen
Reply
Dynamicweb.Notifications.eCommerce.Order.Steps.Completed is related to Cartv1. If you are using Cartv2, use Dynamicweb.Ecom7.Cart.Notifications.CheckoutDoneOrderIsComplete notification.

Originally notifications had an array of objects as it second parameter (we have 23 in total of that type). All new notifications have an object derived from NotificationArgs. So some notifications uses the array approach, and others the NotificationArgs approach.

In DW8 all of them uses the NotificationArgs approach. And Dynamicweb.Ecom7.Cart.Notifications.CheckoutDoneOrderIsComplete is moved to Dynamicweb.Notifications.eCommerce.Cart.CheckoutDoneOrderIsComplete.

Dynamicweb.Ecom7.Cart.Notifications.CheckoutDoneOrderIsComplete uses a NotificationArgs

I know it is a little messy - cleaned it up for DW 8.

 

You must be logged in to post in the forum