gpt4 book ai didi

drupal - 是否可以在不创建新用户帐户的情况下使用 ubercart 进行匿名购买?

转载 作者:行者123 更新时间:2023-12-01 15:58:53 25 4
gpt4 key购买 nike

我希望能够让匿名用户购买产品,但在他们购买产品时不创建新帐户。

不幸的是,新用户的创建似乎非常紧密地集成到 ubercart 的订购系统中。而且,因为订单模块是 ubercart 核心的一部分,所以它的行为不能轻易被覆盖。

覆盖新用户帐户创建的一种可能性是为 ubercart 提供一个虚假的匿名帐户:

在 $form_id == 'uc_cart_checkout_review_form' Hook hook_form_alter,因为这是 ubercart 首先将 $order 与 uid 相关联的地方。将我们的提交函数添加到队列中:

//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;

}

但我真正需要的是能够进行匿名购买而不必被迫创建新帐户,此解决方案对我不起作用。

除此之外,使用此技术会自动将 anonymous_user 登录到我们的 bogus_anonymous_user 帐户。这绝对是我不想要的。

在 ubercart 中为匿名购买创建新用户帐户是否有更好的非胶带方法?

仅供引用 - 在这一点上,我有点受困于 ubercart,所以我不能使用其他东西。

谢谢!

D


更新:


我一直想指出的是,用户不一定会像上面所说的那样自动登录。仅当 session 已保存时才会出现这种情况。但正如 safely impersonating another user 上的一篇文章所示在 Drupal 中,可以如下绕过自动登录:

//Find out if the user is anonymous:
global $user;
if (!$user->uid) {

$original_user = $user;

session_save_session(FALSE); //Prevents the auto login amongst other effects.

//Load admin user
$user = user_load(array('uid' => 1));


//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);

//Set things back to normal.
$user = $original_user;
session_save_session(TRUE);

}

最佳答案

不幸的是,它为匿名用户创建帐户,因此用户可以登录并查看他们的发票、订单历史记录等。

您可以只关闭发送的电子邮件而不激活帐户。这是在配置 > 结帐中:

Send new customers a separate e-mail with their account details.
New customer accounts will be set to active.

我认为你最好不要破解 Ubercart,因为在那种情况下更新会更难。至少这样,他们不会收到电子邮件,也不知道自己有帐户。

在我的脑海中,你会想要 UID(需要用户帐户),否则每个订单都将是 UID 0,因此基本上不可能有任何类型的报告/ View 或订单历史记录功能错了。

关于drupal - 是否可以在不创建新用户帐户的情况下使用 ubercart 进行匿名购买?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2608588/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com