/**
  * @param \Magento\Sales\Api\Data\OrderAddressInterface $addrMage
  * @return \Praxigento\Odoo\Data\Odoo\Contact
  */
 public function _extractContact(\Magento\Sales\Api\Data\OrderAddressInterface $addrMage)
 {
     $result = $this->_manObj->create(\Praxigento\Odoo\Data\Odoo\Contact::class);
     /* collect data */
     $name = $addrMage->getName();
     $phone = $addrMage->getTelephone();
     $email = $addrMage->getEmail();
     $country = $addrMage->getCountryId();
     $state = $addrMage->getRegionCode();
     $city = $addrMage->getCity();
     $street = $addrMage->getStreet();
     // street data is array
     $street = implode('', $street);
     $zip = $addrMage->getPostcode();
     /* init Odoo data object */
     if ($name) {
         $result->setName($name);
     }
     if ($phone) {
         $result->setPhone($phone);
     }
     if ($email) {
         $result->setEmail($email);
     }
     if ($country) {
         $result->setCountry($country);
     }
     if ($state) {
         $result->setState($state);
     }
     if ($city) {
         $result->setCity($city);
     }
     if ($street) {
         $result->setStreet($street);
     }
     if ($zip) {
         $result->setZip($zip);
     }
     return $result;
 }
 /**
  * Converts Order address into AvaTax compatible data array
  *
  * @param \Magento\Sales\Api\Data\OrderAddressInterface $address
  * @return array
  */
 public function convertOrderAddressToAvaTaxAddress(OrderAddressInterface $address)
 {
     $street = $address->getStreet();
     return ['Line1' => array_key_exists(0, $street) ? $street[0] : '', 'Line2' => array_key_exists(1, $street) ? $street[1] : '', 'Line3' => array_key_exists(2, $street) ? $street[2] : '', 'City' => $address->getCity(), 'Region' => $this->getRegionCodeById($address->getRegionId()), 'PostalCode' => $address->getPostcode(), 'Country' => $address->getCountryId()];
 }
 /**
  * Convert magento address to array for braintree
  *
  * @param \Magento\Sales\Api\Data\OrderAddressInterface $address
  * @return array
  */
 public function toBraintreeAddress($address)
 {
     if ($address) {
         $countryId = $address->getCountryId();
         $region = $address->getRegion();
         if ($countryId == 'US') {
             $region = $this->convertRegionToCode($region, $address->getRegionId());
         }
         $street = $address->getStreet();
         $streetAddress = $street[0];
         return ['firstName' => $address->getFirstname(), 'lastName' => $address->getLastname(), 'company' => $address->getCompany(), 'streetAddress' => $streetAddress, 'extendedAddress' => isset($street[1]) ? $street[1] : null, 'locality' => $address->getCity(), 'region' => $region, 'postalCode' => $address->getPostcode(), 'countryCodeAlpha2' => $countryId];
     } else {
         return [];
     }
 }
Exemple #4
0
 /**
  * Get street line 2
  *
  * @return string
  */
 public function getStreetLine2()
 {
     $street = $this->address->getStreet();
     return isset($street[1]) ? $street[1] : '';
 }