0
if (is_null($this->_address)) {
    if ($this->isCustomerLoggedIn()) {
        $this->_address = $this->getQuote()->getShippingAddress();
    } else {
    $ship = $this->getQuote()->getShippingAddress();
    $ship_country = $ship->getCountryId();
    if(!empty($ship_country))
        $this->_address = $ship;
    else
        $this->_address = Mage::getModel('sales/quote_address');
    }
}

Please reply if you have any idea.

Thanks.

0

Try following way:


/**
 * Get logged in customer
 *
 * @return Mage_Customer_Model_Customer
 */
public function getCustomer()
{
    if (empty($this->_customer)) {
        $this->_customer = Mage::getSingleton('customer/session')->getCustomer();
    }
    return $this->_customer;
}

public function getAddress()
{
    if (is_null($this->_address)) {
        if ($this->isCustomerLoggedIn()) {
            $this->_address = $this->getCustomer()->getPrimaryShippingAddress();
            if(!$this->_address) {
                $this->_address = $this->getQuote()->getShippingAddress();
            }
        } else {
            $ship = $this->getQuote()->getShippingAddress();
            $ship_country = $ship->getCountryId();
            if(!empty($ship_country)) {
                $this->_address = $ship;
            } else {
                $this->_address = Mage::getModel('sales/quote_address');
            }
        }
    }
}
  • thanks for the reply. We need only default selected shipping address in ALT DELIVERY ADDRESS drop down in one-page checkout. – Ashish Kacha Feb 14 '18 at 5:02
  • $this->_address = $this->getCustomer()->getPrimaryShippingAddress(); -> return default shipping address. – Sohel Rana Feb 14 '18 at 7:30
  • sohel => This is not working for getting default address in ALT DELIVERY ADDRESS. – Ashish Kacha Mar 5 '18 at 10:12

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.