Order workflow is a complicated thing, with a lot of triggers and points of entry in which things can change, like stock decrementing, role assignment, etc.

Even more, some triggers are executed even though it's not quite like that, for example, when you create an order as admin, and then you enter a payment from the payment tab in the order, uc_payment_enter() executes uc_complete_sale() which triggers 'customer completes checkout'.

Fixing the workflow is probably not an easy task and I was trying to work out something with rules and I found that what would be really helpful is to be able to identify admin created orders in rules.

The stock decrement is happening twice because when the admin order is edited, stock gets decremented, and when a payment is entered, it tiggers 'customer completes checkout' which decrements stock again.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hanoii’s picture

hanoii’s picture

Title: rules condition for admin created orders to prevent stock decrementing twice » rules condition for admin created orders
hanoii’s picture

Status: Active » Needs review
longwave’s picture

Duplicate of #1216802: Keep record of user orders and admin orders but this is a simpler suggestion that includes a patch. I don't want to implement this twice so we should consider the suggestions there before committing this.

hanoii’s picture

I have read through #1216802: Keep record of user orders and admin orders but is a different approach of the same thing, they add a column while I use the data array. It's true though, that adding some kind of flag to the db would allow for better queries/views integration, but so far this is a good approach and eventually a views integration can be done anyway, only slightly more complicated/less performance.

TR’s picture

Component: Code » Rules

Added "Rules" component.