I would like to be able to have anonymous users purchase a product but not have a new account created when they purchase it.
Unfortunately the creation of a new user seems to be very tightly integrated into ubercart's ordering system. And, because the order module is part of the ubercart core, it's behavior cannot be overridden easily.
One possibility for overriding the creation of a new user account is by supplying ubercart with a bogus anonymous account:
hook into hook_form_alter at $form_id == 'uc_cart_checkout_review_form' because this is where ubercart first associates the $order to an uid. Add our submit function to the queue:
//Find out if the user is anonymous:
global $user;
if ($user->uid == 0 ) {
//Load a previously created anonymous user account
$anonymous_user = mymodule_get_anonymous_user();
//create the order and assign our anonymous_user_id to it
$order = uc_order_load($_SESSION['cart_order']);
$order->uid = $anonymous_user->uid;
uc_order_save($order);
//Assign the global user our anonymous user uid
$user->uid = $anonymous_user->uid;
}
But what I really need is to be able to have an anonymous purchase without being forced to create a new account, this solution does not work for me.
Apart from which, using this technique will automatically login the anonymous_user
into our bogus_anonymous_user
account. Which is definitely something I don't want.
Is there a better non-duct-tape way around the creation of a new user account for anonymous purchases in ubercart?.
AND FYI - at this point I'm kind of stuck with ubercart so I cannot use something else.
Thanks!
D