Search code examples
magentocheckoutaddressbookbilling

Magento - get Customer Address id of order shipping address


I got the shipping address of an order by $order->getShippingAddress()

$order = Mage::getModel('Mage_Sales_Model_Order');
$order->loadByIncrementId($ext_order_id);
$address = $order->getShippingAddress();

and i load the DefaultBillingAddress by

$address_default_billing = Mage::getSingleton('customer/session')->getCustomer()
                                    ->getDefaultBillingAddress();

Now i want to compare them, but there's the problem. If i do a getId() on both of them, they have different id's even though i chose the billing address for shipping in checkout, so they have to be the same but the id is different.. how can that appear ? Is there a way to get the customer-address-id of the current shippingaddress in checkout ?

by example: $address->getId() returns 44 and $address_default_billing->getId() return 6

the 6 is the right id for the customer address in the model, but the order-shipping-id is wrong.


Solution

  • you can get customer address by customer_address_id field in sales_flat_order_address table

    here the code:

    $order = Mage::getModel('sales/order');
    $order->loadByIncrementId($ext_order_id);
    $address = $order->getShippingAddress();
    $address->getData('customer_address_id');