Developer forum

Forum » Development » Need right event/extender, for interacting with cart

Need right event/extender, for interacting with cart

Dmitrij Jazel
Reply

Hi Guys,

 

I have a need for an event/extender, that would be ideal for making some manipulation with the cart.

Than I need to send some feedback back to Front-end.

Ideally event like: PageTemplateExtender - should be good for interacting with the cart.

But the issue is that it is already too late in the DW/DW Ecom lifecycle.

Therefore - all changes added to the cart/order object will not be displayed at once the page loads. As soon as you refresh - than you will see everything working properly.

 

But I need something that would be quite early in the lifecycle. Think this should be quite common.

Appreciate suggestions and help! :)

 

/Dmitrij


Replies

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Hi Dmitrij

The cart is in the context at all times (if present of course) - so you could use Notifications.Standard.Page.Loaded notification subscriber which is pretty early in the process. Then you can just manipulate the order from there - (eCommerce.Common.Context.Cart)

Votes for this answer: 1
 
Dmitrij Jazel
Reply

Hi Nicolai,

Happy new year by the way! :)

Thanks for the tip, sounds really prommising, will give it a try, and will come back with my findinds :)

 

/Dmitrij

 
Dmitrij Jazel
Reply

Hi Nicolai,

It looks like this:

[Subscribe(Dynamicweb.Notifications.Standard.Page.Loaded)]
    public class PageLoaded : NotificationSubscriber
    {
        public override void OnNotify(string notification, Dynamicweb.Extensibility.NotificationArgs args)
        {
            if (args == null)
                return;

            Dynamicweb.Notifications.Standard.Page.LoadedArgs loadedArgs = (Dynamicweb.Notifications.Standard.Page.LoadedArgs)args;
            //Adding Meta Tag to the PageView
            loadedArgs.pageview.Meta.Add("my-metatag", "hello");
        }
    }  

adds very nice Meta-tag.

The event looks good, and I would like to use it.

Now the task is how do I send some data back to the Front-end.

If I could add a tag, or maybe use Item[] object.

So far things like:

var tag = new Dynamicweb.Rendering.Tag("my-globalProducts", "productIDs");
loadedArgs.pageview.GlobalTags.Add(tag);
loadedArgs.pageview.TemplatePage.SetTag("my-products", "prod123");

Did not give any possitive results :-/

 
Dmitrij Jazel
Reply

Attempted to use something like this:

var tag = new Dynamicweb.Rendering.Tag("my-globalProducts", "productIDs"); 
loadedArgs.pageview.Current().TemplatePage.SetTag("my-products", "prod123");

But was not able to use that because in this particular Event Dynamicweb.Notifications.Standard.Page.Loaded

loadedArgs.pageview object does not contain .Current() method.

 

/Dmitrij

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Hi D

Try Dynamicweb.Notifications.Standard.Page.OnOutput or Notifications.Standard.Page.OnGlobalTags if you want to set global tags.

Votes for this answer: 1
 
Dmitrij Jazel
Reply

Hi Nicolai,

Thanks for that one aswell, I will try use those aswell.

I also tryed to use (to send data back to front-end): 

System.Web.HttpContext.Current.Items["my-status"]

It worked quite well. :)

 

/Dmitrij

 

You must be logged in to post in the forum