On the site I am building, I am using the User Domains module, which creates domains upon registration and contains a login hook to allow people to redirect to their domains upon login. In Ubercart checkout configuration, I have the 'Login users when new customer accounts are created at checkout.' option selected.
So what happens is that when the users complete checkout, they are logged into their account and redirected to their domain. However the rest of the code in uc_cart_complete_sale module is never run, specifically the invocation of hook_uc_checkout_complete and (probably more importantly) the conditional action. Presumably this will be true not only for the Domain User module - other modules that carry out actions upon login may also conceivably prevent the hook from being run.
Here's a patch that moves login to after everything else is done so it can't stop the hook from being invoked.
Comment | File | Size | Author |
---|---|---|---|
#4 | uc_cart_new_user_no_redirect.patch | 623 bytes | andeme |
uc_login_activate_hooks.patch | 1016 bytes | nirbhasa | |
Comments
Comment #1
nirbhasa CreditAttribution: nirbhasa commentedHmm - theres a couple of little edits that need to be made to the issue, but dont seem to be able to edit the issue:
- User Domain module is in fact Domain User, as submodule of Domain Access
- 'uc_cart_complete_sale module' is (of course) uc_cart_complete_sale function
Comment #2
nirbhasa CreditAttribution: nirbhasa commentedComment #3
sebagr CreditAttribution: sebagr commented+1 subscribing
Had the same problem, spent half day to find the problem, now I simply disabled automated login after checkout or the invoice emails wouldn't get dispatched.
Comment #4
andeme CreditAttribution: andeme commentedThe current code drupal_execute()'s the user_login form in order to login the new user. Anything in the core user module or any contributed module using hook_user that causes a redirect can prevent further execution of uc_cart_complete_sale.
In my case I need the new user to be created before the uc_checkout_complete trigger is pulled so nirbhasa's solution of moving the drupal_execute call to the end didn't work for me. The attached patch offers an alternative solution that bypasses user_login altogether and logs in the new user by simply assigning the new user in $account to the global $user. This solution works for me because I don't need hook_user to be called in this case. For me it's okay that hook_user only get called when the user logs themselves in normally. My alternative solution won't work if you are using any other modules that do something upon login that must still happen in this special case.
Since neither of these solutions address every use case I'm not sure whether either one should be committed to uc_cart. I'd like to know what the community thinks.
As nrbhasa speculated I can confirm that this issue is the root cause for problems in other modules that depend on the uc_checkout_complete trigger, such as uc_roles and uc_node_access.
Comment #5
torgosPizzaSubscribing. Would like to know some core maintainers thoughts on this.
Comment #6
danielb CreditAttribution: danielb commentedSubscribed. This is causing issues in a few other modules.
Comment #7
akalata CreditAttribution: akalata commentedPatch appears to have cleared up issues I was having with anon purchases and uc_file grants. Applied to 6.x-2.4.
Comment #8
longwaveLooks reasonable, though perhaps we should forcibly unset $account->password to ensure the plaintext password is not available. I also wonder if any side effects will be triggered by not invoking hook_user('login') in some cases, but I can't see any obvious ones.
Comment #9
redsky CreditAttribution: redsky commentedsubscribing
Comment #10
longwaveThis has been fixed in 6.x-2.x-dev as part of #1192018: Duplicate order notification e-mail, and duplicate stock decrement