0

Magento how to update billing/shipping order before place order for guest.

I know what observer event I need to use and familiar with it. What I want to know is how to get billing/shipping or and what code write to update it. I've only found information about how to update a address of already placed order.

0

I did not try this code so you should refine it on your own: you need to have an observer that has a function to update the billing and shipping address, here is what you need to do in your xml:

<sales_order_save_before>
    <observers>
        <custom_observer>
            <type>singleton</type>
            <class>Custom_Module_Model_Observer</class>
            <method>updateaddress</method>
        </custom_observer>
    </observers>
</sales_order_save_before>

then in your observer you need to check if the account is a guest account and then update their quote:

public function updateaddress(Varien_Event_Observer $observer) {
    $session = $observer->getEvent()->getCheckoutSession();
    $sessionCustomer = Mage::getSingleton("customer/session");
    $quote = $this->_quote = Mage::getModel('sales/quote')->setStoreId(Mage::app()->getStore()->getId())->load($session->getQuoteId());
    $address = $quote->getShippingAddress();
    if (!$sessionCustomer->isLoggedIn()) {
        $address->setData($reset);
        $quote->setShippingAddress($address);
        $quote->setBillingAddress($address);
        $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.