protected function USPSShipment::setShipFrom in Commerce USPS 8
Sets the ship from for a given shipment.
1 call to USPSShipment::setShipFrom()
- USPSShipment::buildPackage in src/
USPSShipment.php - Returns an initialized rate package object.
File
- src/
USPSShipment.php, line 55
Class
- USPSShipment
- Class that sets the shipment details needed for the USPS request.
Namespace
Drupal\commerce_uspsCode
protected function setShipFrom() {
/** @var \CommerceGuys\Addressing\Address $address */
$address = $this->commerceShipment
->getOrder()
->getStore()
->getAddress();
$from_address = new Address();
$from_address
->setAddress($address
->getAddressLine1());
$from_address
->setCity($address
->getLocality());
$from_address
->setState($address
->getAdministrativeArea());
// Due to API limitations, only accept the first 5 digits of the Zip Code.
$this->uspsPackage
->setZipOrigination(substr($address
->getPostalCode(), 0, 5));
}