/** * 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|TaxEngine */ public function getDeliveryCountry() { if (null === $this->taxCountry) { /* is there a logged in customer ? */ if (null !== ($customer = $this->session->getCustomerUser())) { if (null !== $this->session->getOrder() && null !== $this->session->getOrder()->getChoosenDeliveryAddress() && null !== ($currentDeliveryAddress = AddressQuery::create()->findPk($this->session->getOrder()->getChoosenDeliveryAddress()))) { $this->taxCountry = $currentDeliveryAddress->getCountry(); } else { $customerDefaultAddress = $customer->getDefaultAddress(); $this->taxCountry = $customerDefaultAddress->getCountry(); } } if (null == $this->taxCountry) { $this->taxCountry = CountryQuery::create()->findOneByByDefault(1); } } return $this->taxCountry; }