duncanmcclean / simple-commerce

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

[5.x] Fix querying the status log #962

Closed duncanmcclean closed 6 months ago

duncanmcclean commented 6 months ago

This pull request fixes an issue where the Status Log field couldn't be queried due to the new format introduced in #956.

After the changes in #956, querying the status log would result in nothing being returned because stuff was being returned in a different format than previously.

// Used to work but doesn't after #956

Entry::query()
    ->where('collection', 'orders')
    ->whereDate('status_log->paid', '>=', '2024-01-01');

This PR essentially maps the new format into what was being returned first - where it's a key/value array with the status and timestamp. This allows for this:

If you have the same status repeated multiple times in your "status log", the latest event of that status will be the one used for querying.

github-actions[bot] commented 6 months ago

Released as part of v5.9.1.