Magento:结帐时使用其他人的地址

发布于 2024-12-18 15:08:38 字数 913 浏览 0 评论 0原文

在我的一个项目中,我需要能够使用其他人的地址下订单。因此,我做了一些修改,以便能够在结账时在我的地址列表中显示其他客户的地址。一切正常,唯一的问题是订单完成后,地址会转移给我,而其他客户将无法再访问该地址。

所以我假设某个地方发生了类似 address->setCustomer($myId) 的事情。 我在 customer/model/customer.php 中评论了这一行:

public function getAddressesCollection()
{
    if (is_null($this->_addressesCollection)) {
        $this->_addressesCollection = $this->getAddressCollection()
            ->setCustomerFilter($this)
            ->addAttributeToSelect('*');
        foreach ($this->_addressesCollection as $address) {
            //$address->setCustomer($this);
        }
        // My call to add other customer's address to the list here
    }

    return $this->_addressesCollection;
}

并且我通过在同一函数中添加类似的内容来添加其他客户的地址: $this->getAddressesCollection()->addItem($customer_address); 但评论这一行“$address->setCustomer($this);”似乎没有效果……

有什么想法吗?

谢谢!

In one of my project, I need to be able to make an order with someone’s else address. So i’ve done some modifications to be able to show the other customer’s addresses in my address list during the checkout. Everything works fine, the only problem is that when the order is completed, the address is transfered to me and the other customer doesn’t have access to this address anymore.

So I assume there is something like address->setCustomer($myId) happening somewhere.
I commented this line in customer/model/customer.php :

public function getAddressesCollection()
{
    if (is_null($this->_addressesCollection)) {
        $this->_addressesCollection = $this->getAddressCollection()
            ->setCustomerFilter($this)
            ->addAttributeToSelect('*');
        foreach ($this->_addressesCollection as $address) {
            //$address->setCustomer($this);
        }
        // My call to add other customer's address to the list here
    }

    return $this->_addressesCollection;
}

And I am adding the other customer’s addresses by adding something like this in the same function :
$this->getAddressesCollection()->addItem($customer_address);
But commenting this line “$address->setCustomer($this);” doesn’t seems to do the trick…

Any idea?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我偏爱纯白色 2024-12-25 15:08:38

我找到的唯一解决方案是强制引用为访客引用。它似乎没有改变结账过程中的任何内容,订单被分配给用户并按通常预期出现在订单列表(客户端和管理端)中。

因此,据我测试,prepareGuestQuote 与prepareCustomerQuote 执行相同的操作,唯一的区别是它不会将所选地址分配给当前客户,因此它似乎解决了我的问题。

在 /checkout/model/type/onepage.php 的 saveOrder() 函数中,更改此:

switch ($this->getCheckoutMethod()) {
        case self::METHOD_GUEST:
            $this->_prepareGuestQuote();
            break;
        case self::METHOD_REGISTER:
            $this->_prepareNewCustomerQuote();
            $isNewCustomer = true;
            break;
        default:
            $this->_prepareCustomerQuote();
            break;
}

为此:

$this->_prepareGuestQuote();

我确信它不是“最佳”解决方案,但它是我发现目前唯一有效的解决方案。

The only solution I found was to force the quote to be a guest quote. It doesn't seem to change anything in the checkout process, the order is assigned to the user and appears in the order list (client side and admin side) as normally expected.

So , as far as I tested, the prepareGuestQuote do the same thing as the prepareCustomerQuote, the only difference is that it doesn't assign the selected address to the current customer, so it seems to fix my problem.

In /checkout/model/type/onepage.php in the saveOrder() function, change this :

switch ($this->getCheckoutMethod()) {
        case self::METHOD_GUEST:
            $this->_prepareGuestQuote();
            break;
        case self::METHOD_REGISTER:
            $this->_prepareNewCustomerQuote();
            $isNewCustomer = true;
            break;
        default:
            $this->_prepareCustomerQuote();
            break;
}

for this :

$this->_prepareGuestQuote();

I'm sure its not the "best" solution, but it is the only thing I found that works for now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文