Closed qualityplatforms closed 6 years ago
You're missing a Group at the very least. See the wiki page for Multi collo shipments.
Also you should loop over $result->getLabels()
, and save them with different names (now you're just overwriting them)
$i=0;
foreach($results->getResponseShipments() as $result)
{
foreach($result->getLabels() as $label)
{
$filename = "label_$i.pdf";
$file = new \SplFileObject($filename, 'w');
$file->fwrite($label->getContent());
$i++;
}
}
Hello there,
I'm using multi-colli labeling from the wiki, but the labels won't been displayed. Only the last label will. I don't know what i'm doing wrong. Here's my code:
`$receiverAddress = ComplexTypes\Address::create() ->setAddressType('01') ->setFirstName($item['first_name']) ->setName($item['name']) ->setCompanyName($item['company']) ->setStreet($item['street']) ->setHouseNr($item['housenr']) ->setHouseNrExt($item['housenr_extra']) ->setZipcode($item['zip']) ->setCity($item['city']) ->setCountrycode($item['country']);
//Set our address $senderAddress = ComplexTypes\Address::create() ->setAddressType('02') ->setFirstName(' ') ->setName(' ') ->setCompanyName('B.V.') ->setStreet('weg') ->setHouseNr('2') ->setHouseNrExt('') ->setZipcode('1111AB') ->setCity('Plaats') ->setCountrycode('NL');
// Create a shipment. $shipment = ComplexTypes\Shipment::create() ->setAddresses(new ComplexTypes\ArrayOfAddress([ $receiverAddress, $senderAddress, ])) ->setBarcode($item['code']) ->setDimension(ComplexTypes\Dimension::create() ->setWeight($item['package_weight'].'00') // Weight in g ->setWidth($item['package_width'].'00') // Width in mm ->setLength($item['package_length'].'00') // Length in mm ->setHeight($item['package_height'].'00') // Height in mm ) ->setProductCodeDelivery('3085');
$results = $client->generateLabelsWithoutConfirm(new ComplexTypes\ArrayOfShipment([$shipment1,$shipment2,$shipment3]));
if(isset($results)) { foreach($results->getResponseShipments() as $result) { // Save the label PDF locally $label = $result->getLabels()[0]; $file = new \SplFileObject("$barcode.pdf", 'w'); file_put_contents("files/label.$barcode.pdf", $label->getContent()); }
}`
There is an foreach from the MySQL database and the code is a bit stripped.
Can any of you have a look on this?
Thanks in advance. Best regards.