From 8744a87c94e447d62ffd2874373bc3d02b3bb464 Mon Sep 17 00:00:00 2001 From: Ibes Date: Fri, 24 Nov 2023 17:04:38 +0100 Subject: [PATCH] Print label form dropoffpoint --- src/Factory/ReceiverFactory.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Factory/ReceiverFactory.php b/src/Factory/ReceiverFactory.php index 069378b..3a640a7 100644 --- a/src/Factory/ReceiverFactory.php +++ b/src/Factory/ReceiverFactory.php @@ -12,6 +12,7 @@ use Sylius\Component\Core\Model\OrderInterface; use Sylius\Component\Core\Model\ShipmentInterface; use TNTExpress\Model\Receiver; +use Webmozart\Assert\Assert; class ReceiverFactory implements ReceiverFactoryInterface { @@ -42,8 +43,13 @@ public function createNew(ShippingGatewayInterface $shippingGateway, ShipmentInt /** @var string $pointId */ $pointId = $shipment->getPickupPointId(); $tntCode = PickupPointCode::createFromString($pointId); + + $splitted = mb_split('###', $tntCode->getIdPart()); + Assert::isArray($splitted, 'Pickup point code is not valid'); + Assert::count($splitted, 3, 'Pickup point code is not valid'); + $receiver->setType('DROPOFFPOINT') - ->setTypeId($tntCode->getIdPart()) + ->setTypeId($splitted[0]) ; } else { $receiver->setType($shippingGateway->getConfigValue('receiver_type'));