Magento 1.9 Shipping Address – Check If Given Address is Default Shipping or Billing Address Using Address ID

billing-addressdefaultmagento-1.9shipping-address

I want to check whether the Given address is Default Shipping or Billing for the Customer address, i have the address id. Can anyone please help me on this.

Best Answer

$addressId = your id here;
$address = Mage::getModel('customer/address')->load($addressId);
$customer = $address->getCustomer();
$defaultBilling = $customer->getDefaultBillingAddress();
if ($defaultBilling) {
    if ($defaultBilling->getId() == $addressId) {
        //is default billing
    } else {
        //is not default billing
    }
} else {
    //is not default billing
}

DO the same for shipping address. Just replace billing with shipping

Related Topic