0

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!

Matt
  • 22,721
  • 17
  • 71
  • 112
Alex Beauchemin
  • 1,072
  • 1
  • 17
  • 24

1 Answers1

0

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.

Alex Beauchemin
  • 1,072
  • 1
  • 17
  • 24