Пример #1
0
 /**
  * Filter the query by a related \Thelia\Model\OrderAddress object
  *
  * @param \Thelia\Model\OrderAddress|ObjectCollection $orderAddress  the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildStateQuery The current query, for fluid interface
  */
 public function filterByOrderAddress($orderAddress, $comparison = null)
 {
     if ($orderAddress instanceof \Thelia\Model\OrderAddress) {
         return $this->addUsingAlias(StateTableMap::ID, $orderAddress->getStateId(), $comparison);
     } elseif ($orderAddress instanceof ObjectCollection) {
         return $this->useOrderAddressQuery()->filterByPrimaryKeys($orderAddress->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByOrderAddress() only accepts arguments of type \\Thelia\\Model\\OrderAddress or Collection');
     }
 }
Пример #2
0
 /**
  * Convert a Thelia address (Address or OrderAddress) to ImmutableAddressInterface
  *
  * @param \Thelia\Model\OrderAddress|OrderAddress $address
  * @return Address|\CommerceGuys\Addressing\Model\ImmutableAddressInterface
  */
 protected function mapTheliaAddress($address, $locale = null)
 {
     $country = $address->getCountry();
     if (null === $locale) {
         $locale = Lang::getDefaultLanguage()->getLocale();
     }
     $customerTitle = $address->getCustomerTitle()->setLocale($this->denormalizeLocale($locale))->getShort();
     $addressModel = new Address();
     $addressModel = $addressModel->withCountryCode($country->getIsoalpha2())->withAddressLine1($address->getAddress1())->withAddressLine2($address->getAddress2())->withPostalCode($address->getZipcode())->withLocality($address->getCity())->withOrganization($address->getCompany())->withRecipient(sprintf('%s %s %s', $customerTitle, $address->getLastname(), $address->getFirstname()));
     if ($country->getHasStates() && intval($address->getStateId()) !== 0) {
         $addressModel = $addressModel->withAdministrativeArea(sprintf('%s-%s', $country->getIsoalpha2(), $address->getState()->getIsocode()));
     }
     return $addressModel;
 }