Developer forum

Forum » Development » OrderTemplateExtender.ExtendTemplate issue

OrderTemplateExtender.ExtendTemplate issue


Reply
 Hi,

I encounter the following issue;

I have made a new Class that derives from OrderTemplateExtender and overrides the "ExtendTemplate" method.

During the order process we want to monitor each step in the process and take certain actions. This works quite well, and no problems so far.
We have an action on step 6 that changes the state of the order, to a specific state.

Now I noticed that this "ExtendTemplate" method is also triggered when a user logs in on the website and goes to the Customer Center to view his orders.
For every order the user has made in the past this method gets triggered and the value of Order.StepNum is 6.

This is currently a problem for me because the template extender I made decides to change the orderstate.

I wonder, is it by design that the OrderTemplateTextender.ExtendTemplate also triggers when viewing the orders through the order history of the Customer Center?

If so, how can I tell the difference between an order that is really in the order process on step 6 or when the order is viewed through the order history of the Customer Center?

Kind Regards,
Emil

Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This is to be expected since the OrderTemplateExtender (and all other template extenders for that matter) has to do with the rendering of templates and, in this case, not the cart flow.

An easy fix (and ugly hack) would be to just look at the page ID in the URL of the current page, and determine from that whether it's the cart page or the Customer Center page.
However I would recommend that you hook into the "Notifications.eCommerce.Order.Steps.Completed" notification instead and let that NotificationSubscriber handle your Step 6 logic. That notification is only broadcast when Step 6 is reached in the cart flow.

I've assumed that you're not using CartV2 because the notifications are a bit different for CartV2. Let me know if you need info on CartV2 instead.
 
Reply
Thanks for your reply !

I was indeed speaking about version 1 of the cart.

Kind Regards,
Emil


 

You must be logged in to post in the forum