Example #1
0
 /**
  * Export region code from address data
  *
  * @param DataObject $address
  * @return string
  */
 protected function getRegion(DataObject $address)
 {
     // get region code, otherwise - region, otherwise - city
     return $address->getRegionCode() ?: ($address->getRegion() ?: $address->getCity());
 }
Example #2
0
 /**
  * Get billing address request data
  *
  * @param \Magento\Framework\DataObject $address
  * @return array
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _getBillingAddress(\Magento\Framework\DataObject $address)
 {
     $region = $address->getRegionCode() ? $address->getRegionCode() : $address->getRegion();
     $request = ['billing_first_name' => $address->getFirstname(), 'billing_last_name' => $address->getLastname(), 'billing_city' => $address->getCity(), 'billing_state' => $region ? $region : $address->getCity(), 'billing_zip' => $address->getPostcode(), 'billing_country' => $address->getCountryId()];
     // convert streets to tow lines format
     $street = $this->_customerAddress->convertStreetLines($address->getStreet(), 2);
     $request['billing_address1'] = isset($street[0]) ? $street[0] : '';
     $request['billing_address2'] = isset($street[1]) ? $street[1] : '';
     return $request;
 }
Example #3
0
 /**
  * @param DataObject $request
  * @param DataObject $shipping
  *
  * @return Object
  */
 public function setShipping($request, $shipping)
 {
     $request->setShiptofirstname($shipping->getFirstname())->setShiptolastname($shipping->getLastname())->setShiptostreet(implode(' ', $shipping->getStreet()))->setShiptocity($shipping->getCity())->setShiptostate($shipping->getRegionCode())->setShiptozip($shipping->getPostcode())->setShiptocountry($shipping->getCountryId());
     return $request;
 }