From 8a219ade827ef6d32d8b1aacefd0874af704256e Mon Sep 17 00:00:00 2001 From: Joeri van Veen Date: Thu, 21 Nov 2024 15:39:55 +0100 Subject: [PATCH] feat: add receipt code for belgium (#875) --- Helper/Data.php | 12 ++++++++++-- view/adminhtml/templates/new_shipment.phtml | 2 -- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 8bb51f9c..3e9f478f 100755 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -259,15 +259,23 @@ public function consignmentHasShipmentOption(AbstractConsignment $consignment, s /** * Business logic determining what shipment options to show, if any. */ + if (AbstractConsignment::SHIPMENT_OPTION_RECEIPT_CODE === $shipmentOption + && AbstractConsignment::DELIVERY_TYPE_STANDARD !== $consignment->getDeliveryType() + ) { + return false; // receipt code is only available for standard delivery + } + if (AbstractConsignment::CC_NL === $consignment->getCountry()) { return $consignment->canHaveShipmentOption($shipmentOption); } - // For PostNL in Belgium - only recipient-only/signature is available + // For PostNL in Belgium - recipient-only, signature and receipt code are available if (AbstractConsignment::CC_BE === $consignment->getCountry() && CarrierPostNL::NAME === $consignment->getCarrierName()) { return in_array($shipmentOption, [ AbstractConsignment::SHIPMENT_OPTION_ONLY_RECIPIENT, - AbstractConsignment::SHIPMENT_OPTION_SIGNATURE], true); + AbstractConsignment::SHIPMENT_OPTION_SIGNATURE, + AbstractConsignment::SHIPMENT_OPTION_RECEIPT_CODE, + ], true); } // UPS shipment options are available for all countries in the EU diff --git a/view/adminhtml/templates/new_shipment.phtml b/view/adminhtml/templates/new_shipment.phtml index cc57d83f..a135405b 100755 --- a/view/adminhtml/templates/new_shipment.phtml +++ b/view/adminhtml/templates/new_shipment.phtml @@ -147,8 +147,6 @@ foreach ($form->getCarrierSpecificAbstractConsignments() as $abstractConsignment foreach ($abstractConsignment->getAllowedShipmentOptions() as $shipmentOption) { if (AbstractConsignment::SHIPMENT_OPTION_INSURANCE === $shipmentOption || ! $block->consignmentHasShipmentOption($abstractConsignment, $shipmentOption) - || ($shipmentOption === AbstractConsignment::SHIPMENT_OPTION_RECEIPT_CODE - && AbstractConsignment::DELIVERY_TYPE_STANDARD !== $block->getDeliveryType()) ) { continue; }