Skip to content

Commit

Permalink
Print label form dropoffpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ehibes committed Nov 24, 2023
1 parent 66f5094 commit 8744a87
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Factory/ReceiverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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'));
Expand Down

0 comments on commit 8744a87

Please sign in to comment.