From 8f782b2859d3f5c24d942c63799a3ce8cfa215d9 Mon Sep 17 00:00:00 2001 From: Richard Perdaan Date: Thu, 23 Dec 2021 12:57:40 +0100 Subject: [PATCH] fix(pps): export delivery options (#360) * fix(pps): export delivery options --- src/Collection/Fulfilment/OrderCollection.php | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Collection/Fulfilment/OrderCollection.php b/src/Collection/Fulfilment/OrderCollection.php index 7f716bb4..175197e4 100644 --- a/src/Collection/Fulfilment/OrderCollection.php +++ b/src/Collection/Fulfilment/OrderCollection.php @@ -109,19 +109,22 @@ private function getShipmentOptions(AbstractDeliveryOptionsAdapter $deliveryOpti ? $dateTime->format(AbstractOrder::DATE_FORMAT_FULL) : null; - $options = [ - 'package_type' => $deliveryOptions->getPackageTypeId(), - 'delivery_date' => $deliveryDate, - ]; - $shipmentOptions = $deliveryOptions->getShipmentOptions(); - if ($shipmentOptions) { - // Map boolean values of shipment options to integers and add them to the options array. - foreach ($shipmentOptions as $optionKey => $optionValue) { - $options[$optionKey] = (int) $optionValue; - } - } + $options = [ + 'package_type' => $deliveryOptions->getPackageTypeId(), + 'delivery_date' => $deliveryDate, + 'signature' => (int) $shipmentOptions->hasSignature(), + 'only_recipient' => (int) $shipmentOptions->hasOnlyRecipient(), + 'age_check' => (int) $shipmentOptions->hasAgeCheck(), + 'large_format' => (int) $shipmentOptions->hasLargeFormat(), + 'return' => (int) $shipmentOptions->isReturn(), + 'insurance' => [ + 'amount' => $shipmentOptions->getInsurance(), + 'currency' => 'EUR' + ], + 'label_description' => (string) $shipmentOptions->getLabelDescription(), + ]; return $options; }