Problem/Motivation

When having a team / employees entering orders in the admin area for customers (that can't be bothered to do so by themselves) there currently is little (to no) evidence on who placed the order (besides looking at the commerce_log entries in case they have been enabled).

Having extra modules or commerce_log might seem like a legit alternative - but - won't do as soon as the information is needed in views or other reference enabled means.

Proposed resolution

Add an optional `author` field that is being set when using Drupal\commerce_order\Form\OrderAddForm (perhaps there are some other places that would fit the need too).

Remaining tasks

Review and enhance my patch / MR.

User interface changes

Little to none.

API changes

None

Data model changes

Adding a field to orders.

Issue fork commerce-3269294

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

attisan created an issue. See original summary.

attisan’s picture

Status: Active » Needs review

rszrama’s picture

Since we don't really talk about orders having "authors", it would make more sense for this to be the "creator". I'm not sure what the impact of adding a new field would be - will discuss w/ jsacksick in out next roadmap meeting.

rszrama’s picture

Status: Needs review » Needs work
jsacksick’s picture

I agree with Ryan on this, this would make more sense for this to be "creator". Also, is this a UI thing only? Perhaps we should set the value to the current user on order insert (the current user when the order got saved for the first time basically)...

I'm not sure what the impact of adding a new field would be

Well, we've done this in the past, I believe changing an existing field is more "risky" than adding a new field (performance wise).

attisan’s picture

Title: Add author field to orders to be used with backend orders » Add creator field to orders to be used with backend orders
Status: Needs work » Needs review

Thanks for the input. Pushed the suggested changes and went for the preSave variant as hinted by jsacksick (instead of relying on the AddOrderForm BUT decided against unsing getCurrentUserId as the field setDefaultValueCallback. Why? In order not to have the field set for every order but only when orders are placed by a user other than the customer himself (guess that will help when dealing with views / filters ...).

attisan’s picture

As for reviews / public need; I have the feeling this is one of those features you will only need after you have been subject to trouble and are trying to figure out why a given order is in the system.