Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The best practise we have been promoting is that the fulfilment event is "order paid in full".
However, our order conversion / account creation rules only run on "checkout complete", which most often comes after "order paid in full".
This means that at the time of fulfilment the order owner might not be known yet, which makes it impossible to open a recurring order, for example.
The solution is to run 'commerce_checkout_order_convert' and 'commerce_checkout_new_account' on "order paid in full" as well.
Comments
Comment #1
bojanz CreditAttribution: bojanz commentedThis is what I committed to commerce_license_billing:
commerce_payment should implement a similar alter hook.
Comment #2
rszrama CreditAttribution: rszrama commentedIf I may, I'm going to retitle this and make it an open question; the idea is to process our anonymous checkout related rules (new account creation or assignment of orders to existing accounts) either "When an order is first paid in full" or when "Completing the checkout process." I don't think this would cause duplicate account creation attempts, but it's worth checking to ensure when these events are fired synchronously Rules isn't preserving an older version of the order without a uid set.
Can we think of any drawbacks to this idea? Order statuses being changed such that a checkout URL is no longer valid could be one.
Comment #3
bojanz CreditAttribution: bojanz commentedWe definitely want to process on both events because we don't know which will fire first.
Both of them check that order:uid is 0 first, so they shouldn't be able to interfere with each other.
Our dear order locking prevents any synchronous changes.
Comment #4
mr.andrey CreditAttribution: mr.andrey commentedCould this prevent a License from assigning a role?
I've noticed an odd issue on a client's site. When an order is created through a regular checkout process, the license is created and activated and the person is assigned the proper role. When it is created through a recurring order, however, the license is created and activated, but the role is never assigned.
It would make sense that if the event "commerce_payment_order_paid_in_full" is triggered on an anonymous order, it won't assign the role because it doesn't have access to the uid at the time of execution.
Any ideas around this issue?
UPDATE: In my case, the issue was likely the previous License expiration overriding the current active license. There's a patch for this:
https://www.drupal.org/node/2577655