-
Notifications
You must be signed in to change notification settings - Fork 38
Pakjegemak shipment
Sebastiaan Lokhorst edited this page Sep 20, 2017
·
2 revisions
To create a Pakjegemak shipment (pickup at PostNL location), use the right product code (3533
for NL), and add an address with addressType 09
.
See the PostNL example for more information.
First create a API client, as usual:
use DivideBV\Postnl\Postnl;
use DivideBV\Postnl\ComplexTypes;
$client = new Postnl(...);
$receiverAddress = ComplexTypes\Address::create()
// fill in address
$senderAddress = ComplexTypes\Address::create();
// fill in address
$pickupAddress = ComplexTypes\Address::create()
->setAddressType('09')
->setCompanyName(...)
->setStreet(...)
->setHouseNr(...)
->setHouseNrExt(...)
->setZipcode(...)
->setCity(...)
->setCountrycode('NL');
}
$productCode = '3533';
$barcode = $client->generateBarcodeByDestination('NL');
$shipment = ComplexTypes\Shipment::create()
->setBarcode($barcode)
->setProductCodeDelivery($productCode)
$shipment->setAddresses(new ComplexTypes\ArrayOfAddress([
$receiverAddress,
$senderAddress,
$pickupAddress
]));
$result = $client->generateLabel($shipment);
$i = 0;
foreach ($result->getLabels() as $label) {
$filename = "label_{$i}.pdf";
$file = new \SplFileObject($filename, 'w');
$file->fwrite($label->getContent());
$i++;
}