From 4d192343c821f946148c80a0b6d7ec081286ec26 Mon Sep 17 00:00:00 2001 From: "Matthew C. Rice" Date: Wed, 25 Oct 2017 11:22:54 -0400 Subject: [PATCH] Adding Delivery Confirmation functionality to PackageServiceOptions for domestic shipments. Was told by UPS support that: "Please try to request a Adult Signature under PackageServiceOptions and not ShipmentServiceOptions. Usually, ShipmentServiceOptions is for International packages. " When originally using Delivery Confirmation on ShipmentServiceOptions, I was receiving the error, which is now resolved with the committed changes. "The requested accessory option is unavailable between the selected locations." An example of code to utilize this on a domestic shipment is: ``` $deliveryConfirmation = new \Ups\Entity\DeliveryConfirmation; $deliveryConfirmation->setDcisType(2); $packageServiceOptions = new \Ups\Entity\PackageServiceOptions(); $packageServiceOptions->setDeliveryConfirmation($deliveryConfirmation); $package->setPackageServiceOptions($packageServiceOptions); ``` --- src/Entity/PackageServiceOptions.php | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/Entity/PackageServiceOptions.php b/src/Entity/PackageServiceOptions.php index ecaf294c..95699e01 100644 --- a/src/Entity/PackageServiceOptions.php +++ b/src/Entity/PackageServiceOptions.php @@ -42,6 +42,11 @@ class PackageServiceOptions implements NodeInterface */ private $holdForPickup; + /** + * @var DeliveryConfirmation + */ + private $deliveryConfirmation; + /** * @param null $parameters */ @@ -60,6 +65,9 @@ public function __construct($parameters = null) if (isset($parameters->HoldForPickup)) { $this->setHoldForPickup($parameters->HoldForPickup); } + if (isset($parameters->DeliveryConfirmation)) { + $this->setDeliveryConfirmation($parameters->DeliveryConfirmation); + } } } @@ -87,6 +95,9 @@ public function toNode(DOMDocument $document = null) if ($this->getHazMatPackageInformation() !== null) { $node->appendChild($this->getHazMatPackageInformation()->toNode($document)); } + if (isset($this->deliveryConfirmation)) { + $node->appendChild($this->deliveryConfirmation->toNode($document)); + } return $node; } @@ -194,4 +205,22 @@ public function setHazMatPackageInformation($hazMatPackageInformation) { $this->hazMatPackageInformation = $hazMatPackageInformation; } + + /** + * @param DeliveryConfirmation $deliveryConfirmation + * @return ShipmentServiceOptions + */ + public function setDeliveryConfirmation(DeliveryConfirmation $deliveryConfirmation) + { + $this->deliveryConfirmation = $deliveryConfirmation; + return $this; + } + + /** + * @return DeliveryConfirmation|null + */ + public function getDeliveryConfirmation() + { + return $this->deliveryConfirmation; + } }