Magento:结帐时使用其他人的地址
在我的一个项目中,我需要能够使用其他人的地址下订单。因此,我做了一些修改,以便能够在结账时在我的地址列表中显示其他客户的地址。一切正常,唯一的问题是订单完成后,地址会转移给我,而其他客户将无法再访问该地址。
所以我假设某个地方发生了类似 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到的唯一解决方案是强制引用为访客引用。它似乎没有改变结账过程中的任何内容,订单被分配给用户并按通常预期出现在订单列表(客户端和管理端)中。
因此,据我测试,prepareGuestQuote 与prepareCustomerQuote 执行相同的操作,唯一的区别是它不会将所选地址分配给当前客户,因此它似乎解决了我的问题。
在 /checkout/model/type/onepage.php 的 saveOrder() 函数中,更改此:
为此:
我确信它不是“最佳”解决方案,但它是我发现目前唯一有效的解决方案。
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 :
for this :
I'm sure its not the "best" solution, but it is the only thing I found that works for now.