public function getDeliveryCountry()
    {
        if (null === $this->taxCountry) {
            /* is there a logged in customer ? */
            /** @var Customer $customer */
            if (null !== $customer = $this->getSession()->getCustomerUser()) {
                if (null !== $this->getSession()->getOrder()
                        && null !== $this->getSession()->getOrder()->getChoosenDeliveryAddress()
                        && null !== $currentDeliveryAddress = AddressQuery::create()->findPk($this->getSession()->getOrder()->getChoosenDeliveryAddress())) {
                    $this->taxCountry = $currentDeliveryAddress->getCountry();
                    $this->taxState = $currentDeliveryAddress->getState();
                } else {
                    $customerDefaultAddress = $customer->getDefaultAddress();
                    if (isset($customerDefaultAddress)) {
                      $this->taxCountry = $customerDefaultAddress->getCountry();
                      $this->taxState = $customerDefaultAddress->getState();
                    }
                }
            }

            if (null == $this->taxCountry) {
                $this->taxCountry = CountryQuery::create()->findOneByByDefault(1);
                $this->taxState = null;
            }
        }

        return $this->taxCountry;
    }
public function getDeliveryCountry()
    {
        if (null === $this->taxCountry) {
            /* is there a logged in customer ? */
            /** @var Customer $customer */
            if (null !== $customer = $this->getSession()->getCustomerUser()) {
                if (null !== $this->getSession()->getOrder()
                        && null !== $this->getSession()->getOrder()->getChoosenDeliveryAddress()
                        && null !== $currentDeliveryAddress = AddressQuery::create()->findPk($this->getSession()->getOrder()->getChoosenDeliveryAddress())) {
                    $this->taxCountry = $currentDeliveryAddress->getCountry();
                    $this->taxState = $currentDeliveryAddress->getState();
                } else {
                    $customerDefaultAddress = $customer->getDefaultAddress();
                    if (isset($customerDefaultAddress)) {
                      $this->taxCountry = $customerDefaultAddress->getCountry();
                      $this->taxState = $customerDefaultAddress->getState();
                    }
                }
            }

            if (null == $this->taxCountry) {
                $this->taxCountry = CountryQuery::create()->findOneByByDefault(1);
                $this->taxState = null;
            }
        }

        return $this->taxCountry;
    }
public function getDeliveryCountry ( ) { if ( null === $ this -> taxCountry ) { /* is there a logged in customer ? */ /** @var Customer $customer */ if ( null !== $ customer = $ this -> getSession ( ) -> getCustomerUser ( ) ) { if ( null !== $ this -> getSession ( ) -> getOrder ( ) && null !== $ this -> getSession ( ) -> getOrder ( ) -> getChoosenDeliveryAddress ( ) && null !== $ currentDeliveryAddress = AddressQuery :: create ( ) -> findPk ( $ this -> getSession ( ) -> getOrder ( ) -> getChoosenDeliveryAddress ( ) ) ) { $ this -> taxCountry = $ currentDeliveryAddress -> getCountry ( ) ; $ this -> taxState = $ currentDeliveryAddress -> getState ( ) ; } else { $ customerDefaultAddress = $ customer -> getDefaultAddress ( ) ; if ( isset ( $ customerDefaultAddress ) ) { $ this -> taxCountry = $ customerDefaultAddress -> getCountry ( ) ; $ this -> taxState = $ customerDefaultAddress -> getState ( ) ; } } } if ( null == $ this -> taxCountry ) { $ this -> taxCountry = CountryQuery :: create ( ) -> findOneByByDefault ( 1 ) ; $ this -> taxState = null ; } } return $ this -> taxCountry ; }
Find Tax Country Id
First look for a picked delivery address country
Then look at the current customer default address country
Else look at the default website country

@return null|Country
Find Tax Country Id First look for a picked delivery address country Then look at the current customer default address country Else look at the default website country