duncanmcclean / simple-commerce

A simple, yet powerful e-commerce addon for Statamic.
https://statamic.com/addons/duncanmcclean/simple-commerce
Other
143 stars 36 forks source link

[5.x] Status Log Improvements #954

Closed duncanmcclean closed 8 months ago

duncanmcclean commented 8 months ago

This pull request makes some improvements to the Status Log that keeps track of status changes on orders.

Changes to the format

Currently, an order's status log is stored like this:

status_log:
  paid: '2023-12-21 00:56'
  placed: '2023-12-21 00:56'

This is fine. However, it comes with one main downside: there's no way of storing status-related metadata, like who updated an order's status or why.

This PR fixes that by changing the format the status log is saved in. Here's how the status_log is saved after this change:

status_log:
  -
    status: paid
    timestamp: 1703120160
    data: { }
  -
    status: placed
    timestamp: 1703120160
    data: { }

In order to avoid introducing breaking changes, Simple Commerce will continue to read the old format, then whenever status changes happen, the status log will be saved in its new format.

Changes to the "Update Order Status" action

This PR adds a new "Reason" field to the "Update Order Status" action. This is an optional text field where additional context can be provided about a status change, which will be visible in the order's status log (which is coming soon! 👀 ).

CleanShot 2023-12-22 at 00 10 40

API Changes

If you were using the PHP API for getting status log information, you'll notice a few things have changed:

To Do

duncanmcclean commented 8 months ago

While creating this PR, I've realised that an order is probably never going to hit the same status twice so this new format isn't really needed.

I'm going to close this PR for now and I can re-open in the future if it's needed.

duncanmcclean commented 8 months ago

Nevermind... found some other reasons we probably want this format:

github-actions[bot] commented 8 months ago

Released as part of v5.7.0.