public function UPSShipment::setShipFrom in Commerce UPS 8.3
Sets the ship from for a given shipment.
Parameters
\Ups\Entity\Shipment $api_shipment: A Ups API shipment object.
1 call to UPSShipment::setShipFrom()
- UPSShipment::getShipment in src/
UPSShipment.php - Creates and returns a UPS API shipment object.
File
- src/
UPSShipment.php, line 92
Class
- UPSShipment
- Class to create and return a UPS API shipment object.
Namespace
Drupal\commerce_upsCode
public function setShipFrom(APIShipment $api_shipment) {
/** @var \CommerceGuys\Addressing\AddressInterface $address */
$address = $this->shipment
->getOrder()
->getStore()
->getAddress();
$from_address = new Address();
$from_address
->setAddressLine1($address
->getAddressLine1());
$from_address
->setAddressLine2($address
->getAddressLine2());
$from_address
->setCity($address
->getLocality());
$from_address
->setCountryCode($address
->getCountryCode());
$from_address
->setStateProvinceCode($address
->getAdministrativeArea());
$from_address
->setPostalCode($address
->getPostalCode());
$ship_from = new ShipFrom();
$ship_from
->setAddress($from_address);
$api_shipment
->setShipFrom($ship_from);
}