Developer forum

Forum » Ecommerce - Standard features » Order Modified date not updated

Order Modified date not updated

Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi,

 

It looks to me that the order modified date is not updated when we add something to the cart. Is this a bug or by design?

https://www.screencast.com/t/BsJqFthVMXXe

 

I am looking for a timestamp for when the order data has changed, whether that's addresses, orderline pricing or quantities or voucher codes,... Order.Modified seems like the proper way to go, but it's not updating correctly.

 

I am using 9.4.6

 

Best Regards,

Nuno Aguiar


Replies

 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply

Hi Nuno,

The tag is not changed with the updating in frontend. That is updated when order is completed or on saving in backend order details. The same behavior is on DW89 as well.

BR, Oleg QA

 

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Oleg,

 

Ok, so it there any way (without susbscribing to a ton of events) to figure out if/when something relevant in the order has changed? Cart quantity and Last modified orderline date?

 

By relevant I mean:

  • Orderline data like names, pricing, qty
  • Addresses, Voucher Code

 

Essentially I am looking for any data the user might enter and or be relevant to the user. My goal is store some flags in sessionStorage and render the same data in my master layout. If they don't match, it means the cart has been updated, and then we trigger an AJAX call to get all of the cart contents we need.

 

Currently this is benefitial when we have some Live Integration and/or because we don't want to request order tags (such as orderline loops) which can decrease performance, if the cart is the same.

 

We haven't started using ViewModels yet, so that could also be a solution that does not affect performance (I honestly don't know), but last I saw they, CartViewModel did not take Cart Contexts into account, which we need. Can you tell me if they do now and/or if VIewModels are better for performance than DW tags?

 

Best Regards,

Nuno Aguiar

 
Nicolai Pedersen
Reply

Hi Nuno

I do not fully understand your question...

An order has a modified data for when that record was last saved to database and so do the orderlines...

So look either or both - or use notifications.

BR Nicolai

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

>> An order has a modified data for when that record was last saved to database and so do the orderlines

Then it must be a bug. If you take a look at my screencast https://www.screencast.com/t/BsJqFthVMXXe where I demo that after adding/updating orderlines the Modified date does not change. If you take a look at the 2 or 3 seconds you can see that the cart quantity has been updated, but the modified date has not.

 

Can you confirm that?

 

Best Regards,

Nuno Aguiar

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

It's two separate things: Order.Modified != OrderLine.Modified. So, when you update a line, the Order.Modified is not affected. And likewise, if you change something on order, none of the lines are changed.

See the email I sent you yesterday; it contains a code example for what NP is suggesting here: "So look either or both"

Imar

 
Nicolai Pedersen
Reply

@Imar: Exactly!

 
Nicolai Pedersen
Reply

Or do something glike this

var lineLastModified = cart.OrderLines.OrderByDescending((OrderLine ol) => ol.Modified).FirstOrDefault().Modified;

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Yeah, this is what I recommended yesterday:

var lineModifed = order.OrderLines.Max(x => x.Modified); // Gets the latest changed date on the line, requires at least one line to be present
var modified = lineModifed > order.Modified ? lineModifed : order.Modified;

which looks at the order and its lines....

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Thank you both.

 

@Imar: I understand. But I misunderstood what Nicolai said, so I wanted to confirm. I will use that approach.

 

You must be logged in to post in the forum