1

I am trying to bring some of the order status history from my clients commerce shop orders into a web page. I seem to be able to get the Current/Previous Status (prevStatus/newStatus.name), but cannot seem to get the elements in the attached image - 'Updated By' and 'Date'.

I have tried a few different tags e.g. 'order.orderStatus.date|datetime' but they just seem to update the the time 'now' rather than the time of the order status change.

Its probably an obvious answer but i cant find this tag to output- if anyone can help that would be great

Thanks Malcolm

Order Status History

2

Try

{% set recentHistory = order.histories|first %} // get the first order history item
{{ recentHistory.dateCreated|date ?? 'no history record' }}

there is no date attribute on an order history model, just the dateCreated. So in effect you are passing null to the |date filter which will default to the current time/date.

You were trying to access the current order status model on the order. There is no dateCreated on the order status model, only the model itself. The date the order status was applied is in the orderHistory models.

3
  • Thanks Luke, I tried that and for some reason it always seems to default to the current date/time 'now' not sure why - would have thought I would get an error if it was the wrong tag. Aug 26 '20 at 12:28
  • Looks like you hit a bug, track here: github.com/craftcms/commerce/issues/1676 Aug 27 '20 at 5:38
  • wasn't a bug, just confused over the history model vs the order status model Aug 27 '20 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.