Magento Guest Checkout – Getting Shipping and Billing Addresses from Guest-Checkout Order

addressbillingcustomeree-1.12shipping

For orders checked out by a non-registered customer (i.e. guest), Magento doesn't create a customer. However, it does store the address information in sales_flat_order_address. How do you access this data? Under this table, there are columns like firstname, lastname, address_type (billing/shipping), etc. which are what I need.

I tried loading the order object (sales/order), thinking the associated table data would be available from this, but they don't seem to be. Since I can't get the entity_ids of sales_flat_order_address corresponding to an order in sales_flat_order, how would I get the shipping and billing address in this case? I am not able to load by the parent_id, which is the row ID of the main order table, either.

I can access sales_flat_order_payment data via ->getPayment(), but ->getAddress(es)() doesn't seem to work.

Any ideas?

Best Answer

Let's say that you have the order id 10000015: So

$orderId = '10000015';
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
$billingAddress = $order->getBillingAddress();
$shippingAddress = $order->getShippingAddress();
Related Topic