protected function getCustomerAddress()
    {
        $deliveryAddress = null;
        $addressId = $this->getSession()->getOrder()->getChoosenDeliveryAddress();
        if (null === $addressId) {
            $customer = $this->getSecurityContext()->getCustomerUser();

            $deliveryAddress = AddressQuery::create()
                ->filterByCustomerId($customer->getId())
                ->orderByIsDefault(Criteria::DESC)
                ->findOne();

            if (null !== $deliveryAddress) {
                $this->getSession()->getOrder()->setChoosenDeliveryAddress(
                    $deliveryAddress->getId()
                );
            }
        } else {
            $deliveryAddress = AddressQuery::create()->findPk($addressId);
        }

        return $deliveryAddress;
    }
protected function getCustomerAddress()
    {
        $deliveryAddress = null;
        $addressId = $this->getSession()->getOrder()->getChoosenDeliveryAddress();
        if (null === $addressId) {
            $customer = $this->getSecurityContext()->getCustomerUser();

            $deliveryAddress = AddressQuery::create()
                ->filterByCustomerId($customer->getId())
                ->orderByIsDefault(Criteria::DESC)
                ->findOne();

            if (null !== $deliveryAddress) {
                $this->getSession()->getOrder()->setChoosenDeliveryAddress(
                    $deliveryAddress->getId()
                );
            }
        } else {
            $deliveryAddress = AddressQuery::create()->findPk($addressId);
        }

        return $deliveryAddress;
    }
protected function getCustomerAddress ( ) { $ deliveryAddress = null ; $ addressId = $ this -> getSession ( ) -> getOrder ( ) -> getChoosenDeliveryAddress ( ) ; if ( null === $ addressId ) { $ customer = $ this -> getSecurityContext ( ) -> getCustomerUser ( ) ; $ deliveryAddress = AddressQuery :: create ( ) -> filterByCustomerId ( $ customer -> getId ( ) ) -> orderByIsDefault ( Criteria :: DESC ) -> findOne ( ) ; if ( null !== $ deliveryAddress ) { $ this -> getSession ( ) -> getOrder ( ) -> setChoosenDeliveryAddress ( $ deliveryAddress -> getId ( ) ) ; } } else { $ deliveryAddress = AddressQuery :: create ( ) -> findPk ( $ addressId ) ; } return $ deliveryAddress ; }
Retrieve the chosen delivery address for a cart or the default customer address if not exists

@return null|Address
Retrieve the chosen delivery address for a cart or the default customer address if not exists