Skip Order Refresh on draft anonymous orders on CLI

Created on 3 August 2023, over 1 year ago
Updated 23 August 2023, over 1 year ago

Given:

  • An Order Type with Refresh Mode set to "Customer"
  • A draft order whose customer uid == 0
  • A CLI process that loads the order e.g. search_api
  • The CLI process is running as uid == 0 (Which is the default behavior)

Expected result:
The order is NOT refreshed when it is loaded.

Actual result:
The order IS refreshed when loaded.

Details:
This causes inconsistent behavior, as only "anonymous" draft orders are refreshed, but not draft orders associated with a user.

Another inconsistent behavior is if you run the process from the web UX, (again, using search indexing as an example) the administrative user will have a uid > 0, and therefore the anonymous orders will NOT be refreshed when indexing.

While there might be a use case for wanting the order to be refreshed from the CLI, it most likely would expect the behavior to be consistent between both anonymous and non-anonymous draft orders.

I would also posit that we shouldn't refresh order types with RefreshMode == 'Always' during CLI processing either, but am reticent to change the meaning of 'Always'. :)

A side effect of this is that the changed date is updated, extending the window of this draft anonymous order for stale cart purging.

It is a small change to avoid a refresh in this scenario.

Patch to follow.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Order

Created by

🇺🇸United States TomTech

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024