I would like to be able to purchase an product by anonymous users, but not have a new account created when I purchased it.
Unfortunately, creating a new user seems to be very tightly integrated into the ubercart ordering system. And since the order module is part of the ubercart kernel, its behavior cannot be easily overridden.
One possibility to override the creation of a new user account is to provide ubercart with a false anonymous account:
bind hook_form_alter to $ form_id == 'uc_cart_checkout_review_form', because that's where ubercart binds $ order to uid. Add our submit function to the queue:
global $user;
if ($user->uid == 0 ) {
$anonymous_user = mymodule_get_anonymous_user();
$order = uc_order_load($_SESSION['cart_order']);
$order->uid = $anonymous_user->uid;
uc_order_save($order);
$user->uid = $anonymous_user->uid;
}
, , .
, , anonymous_user bogus_anonymous_user. .
ubercart?.
FYI - ubercart, - .
!
D
Update:
, , , . , . , Drupal, :
global $user;
if (!$user->uid) {
$original_user = $user;
session_save_session(FALSE);
$user = user_load(array('uid' => 1));
$order = uc_order_load($_SESSION['cart_order']);
$order->uid = $anonymous_user->uid;
uc_order_save($order);
$user = $original_user;
session_save_session(TRUE);
}