protected function getDeliveryInformation(Customer $customer = null)
    {
        $address = null;
        // get the selected delivery address
        if (null !== $addressId = $this->getCurrentRequest()->getSession()->getOrder()->getChoosenDeliveryAddress()) {
            if (null !== $address = AddressQuery::create()->findPk($addressId)) {
                $this->isCustomizable = false;
                return [$address, $address->getCountry(), null];
            }
        }

        // get country from customer addresses
        if (null !== $customer) {
            $address = AddressQuery::create()
                ->filterByCustomerId($customer->getId())
                ->filterByIsDefault(1)
                ->findOne()
            ;

            if (null !== $address) {
                $this->isCustomizable = false;

                return [$address, $address->getCountry(), null];
            }
        }

        // get country from cookie
        $cookieName = ConfigQuery::read('front_cart_country_cookie_name', 'fcccn');
        if ($this->getCurrentRequest()->cookies->has($cookieName)) {
            $cookieVal = $this->getCurrentRequest()->cookies->getInt($cookieName, 0);
            if (0 !== $cookieVal) {
                $country = CountryQuery::create()->findPk($cookieVal);
                if (null !== $country) {
                    return [null, $country, null];
                }
            }
        }

        // get default country for store.
        try {
            $country = Country::getDefaultCountry();

            return [null, $country, null];
        } catch (\LogicException $e) {
            ;
        }

        return [null, null, null];
    }
protected function getDeliveryInformation(Customer $customer = null)
    {
        $address = null;
        // get the selected delivery address
        if (null !== $addressId = $this->getCurrentRequest()->getSession()->getOrder()->getChoosenDeliveryAddress()) {
            if (null !== $address = AddressQuery::create()->findPk($addressId)) {
                $this->isCustomizable = false;
                return [$address, $address->getCountry(), null];
            }
        }

        // get country from customer addresses
        if (null !== $customer) {
            $address = AddressQuery::create()
                ->filterByCustomerId($customer->getId())
                ->filterByIsDefault(1)
                ->findOne()
            ;

            if (null !== $address) {
                $this->isCustomizable = false;

                return [$address, $address->getCountry(), null];
            }
        }

        // get country from cookie
        $cookieName = ConfigQuery::read('front_cart_country_cookie_name', 'fcccn');
        if ($this->getCurrentRequest()->cookies->has($cookieName)) {
            $cookieVal = $this->getCurrentRequest()->cookies->getInt($cookieName, 0);
            if (0 !== $cookieVal) {
                $country = CountryQuery::create()->findPk($cookieVal);
                if (null !== $country) {
                    return [null, $country, null];
                }
            }
        }

        // get default country for store.
        try {
            $country = Country::getDefaultCountry();

            return [null, $country, null];
        } catch (\LogicException $e) {
            ;
        }

        return [null, null, null];
    }
protected function getDeliveryInformation ( Customer $ customer = null ) { $ address = null ; // get the selected delivery address if ( null !== $ addressId = $ this -> getCurrentRequest ( ) -> getSession ( ) -> getOrder ( ) -> getChoosenDeliveryAddress ( ) ) { if ( null !== $ address = AddressQuery :: create ( ) -> findPk ( $ addressId ) ) { $ this -> isCustomizable = false ; return [ $ address , $ address -> getCountry ( ) , null ] ; } } // get country from customer addresses if ( null !== $ customer ) { $ address = AddressQuery :: create ( ) -> filterByCustomerId ( $ customer -> getId ( ) ) -> filterByIsDefault ( 1 ) -> findOne ( ) ; if ( null !== $ address ) { $ this -> isCustomizable = false ; return [ $ address , $ address -> getCountry ( ) , null ] ; } } // get country from cookie $ cookieName = ConfigQuery :: read ( 'front_cart_country_cookie_name' , 'fcccn' ) ; if ( $ this -> getCurrentRequest ( ) -> cookies -> has ( $ cookieName ) ) { $ cookieVal = $ this -> getCurrentRequest ( ) -> cookies -> getInt ( $ cookieName , 0 ) ; if ( 0 !== $ cookieVal ) { $ country = CountryQuery :: create ( ) -> findPk ( $ cookieVal ) ; if ( null !== $ country ) { return [ null , $ country , null ] ; } } } // get default country for store. try { $ country = Country :: getDefaultCountry ( ) ; return [ null , $ country , null ] ; } catch ( \ LogicException $ e ) { ; } return [ null , null , null ] ; }
Retrieve the delivery country for a customer

The rules :
- the country of the delivery address of the customer related to the
cart if it exists
- the country saved in cookie if customer have changed
the default country
- the default country for the shop if it exists


@param  \Thelia\Model\Customer $customer
@return \Thelia\Model\Country
Retrieve the delivery country for a customer