0

I'm customizing a magento store and I have the following problem.

Imagine that a customer of the store has 4 different delivery addresses, addresses already registered in the system.

Due to the customization I am making, I offer the customer who is buying in the store the option to choose which address he wants to deliver through a <select>, on a page outside the magento.

I have the deed code in the database, that is, the entity_id number for the address I want to change in the request that is in progress, according to the client's selection.

And that's exactly where my problem lies:

I need to tell the magento the address code I want to use at the checkout to finalize the order.

Magento by default, throws the client's default address in the ShippingAddress

Example of what I need: $checkout->setShippingAddress(entity_id), however, I can not make it work.

using the command below, I can get all the data from the checkout open:

Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getData();

I need to change the delivery address to a new address, which is already registered in the system.

Can someone help me?

I do not know what to do anymore.

Thanks in advance for your help.

0

You can try this way :

$quote = Mage::getSingleton('checkout/session')->getQuote();
$address = $quote->getShippingAddress();
$customerAddress = Mage::getModel('customer/address')->load($customerAddressId);
if ($customerAddress->getId()) {
    $address->importCustomerAddress($customerAddress)->setSaveInAddressBook(0);
}
$quote->collectTotals()->save();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.