/**
  * @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;
 }
Ejemplo n.º 2
0
 /**
  * Declare order shipping address
  *
  * @param \Magento\Sales\Api\Data\OrderAddressInterface $address
  * @return $this
  */
 public function setShippingAddress(\Magento\Sales\Api\Data\OrderAddressInterface $address = null)
 {
     $old = $this->getShippingAddress();
     if (!empty($old) && !empty($address)) {
         $address->setId($old->getId());
     }
     if (!empty($address)) {
         $address->setEmail($this->getCustomerEmail());
         $this->addAddress($address->setAddressType('shipping'));
     }
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * 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()];
 }
Ejemplo n.º 4
0
 /**
  * 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 [];
     }
 }
 public function testGetEmail()
 {
     $expected = '*****@*****.**';
     $this->orderAddressMock->expects($this->once())->method('getEmail')->willReturn($expected);
     $this->assertEquals($expected, $this->model->getEmail());
 }
Ejemplo n.º 6
0
 /**
  * Returns name suffix
  *
  * @return string
  */
 public function getSuffix()
 {
     return $this->address->getSuffix();
 }
Ejemplo n.º 7
0
 /**
  * Get company
  *
  * @return string
  */
 public function getCompany()
 {
     return $this->address->getCompany();
 }
Ejemplo n.º 8
0
 /**
  * Get billing/shipping email
  *
  * @return string
  */
 public function getEmail()
 {
     return $this->address->getEmail();
 }