/** * Compare two addresses to have the same data. * * @param AddressInterface|null * @param AddressInterface|null * @return bool */ public function compareAddresses(AddressInterface $a = null, AddressInterface $b = null) { // If either is null, cannot be matching addresses. if (!$a || !$b) { return false; } return $a->getStreet() === $b->getStreet() && $a->getCity() === $b->getCity() && $a->getRegionCode() === $b->getRegionCode() && $a->getPostcode() === $b->getPostcode() && $a->getCountryId() === $b->getCountryId(); }
/** * Transfer data from an address validation address to a customer address. * * @param CustomerAddressInterface * @param AddressInterface|null * @return CustomerAddressInterface */ public function transferDataAddressToCustomerAddress(CustomerAddressInterface $customerAddress, AddressInterface $dataAddress = null) { if ($dataAddress) { $region = $customerAddress->getRegion(); $region->setRegionCode($dataAddress->getRegionCode())->setRegionId($dataAddress->getRegionId())->setRegion($dataAddress->getRegionName()); $customerAddress->setStreet($dataAddress->getStreet())->setCity($dataAddress->getCity())->setCountryId($dataAddress->getCountryId())->setPostcode($dataAddress->getPostcode())->setRegion($region); } return $customerAddress; }
public function getAddressHtml(AddressInterface $address) { return sprintf('%s<br/>%s %s %s %s', implode('<br/>', $address->getStreet()), $address->getCity(), $address->getRegionCode(), $address->getCountryId(), $address->getPostcode()); }
/** * Transfer the Magento address object to a physical address SDK payload. * * @param AddressInterface * @param IPhysicalAddress * @return IPhysicalAddress */ public function transferAddressToPhysicalAddressPayload(AddressInterface $address, IPhysicalAddress $addressPayload) { $addressPayload->setLines(implode("\n", (array) $address->getStreet()))->setCity($address->getCity())->setMainDivision($address->getRegionCode())->setCountryCode($address->getCountryId())->setPostalCode($address->getPostcode()); return $addressPayload; }