-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,23 +30,33 @@ foreach ($client->getShippingMethods() as $shippingMethod) { | |
try { | ||
// Most of these arguments are optional and will fall back to defaults configured in Sendcloud | ||
$parcel = $client->createParcel( | ||
new Address('Customer name', 'Customer company name', 'Customer street', '4A', 'City', '9999ZZ', 'NL', '[email protected]', '+31612345678'), | ||
null, // Service point ID | ||
'20190001', // Order number | ||
2500, // Weight (2.5kg) | ||
shippingAddress: new Address( | ||
name: 'John Doe', | ||
companyName: 'Big Box Co.', | ||
addressLine1: 'Office Street 2834A', | ||
city: 'Metropolis', | ||
postalCode: '9999ZZ', | ||
countryCode: 'NL', | ||
emailAddress: '[email protected]', | ||
phoneNumber: '+31612345678' | ||
), | ||
servicePointId: null, | ||
orderNumber: '20190001', | ||
weight: 2500, // 2.5kg | ||
// Below options are only required when shipping outside the EU | ||
'customsInvoiceNumber', | ||
Parcel::CUSTOMS_SHIPMENT_TYPE_COMMERCIAL_GOODS, | ||
[ | ||
customsInvoiceNumber: 'CI-8329823', | ||
customsShipmentType: Parcel::CUSTOMS_SHIPMENT_TYPE_COMMERCIAL_GOODS, | ||
items: [ | ||
new ParcelItem('green tea', 1, 123, 15.20, '090210', 'EC'), | ||
new ParcelItem('cardboard', 3, 50, 0.20, '090210', 'NL'), | ||
] | ||
], | ||
postNumber: 'PO BOX 42', | ||
); | ||
|
||
$parcel = $client->createLabel( | ||
$parcel, | ||
8, // Shipping method ID | ||
null // Default sender address | ||
parcel: $parcel, | ||
shippingMethod: 8, | ||
senderAddress: null, // Default sender address. | ||
); | ||
|
||
$pdf = $client->getLabelPdf($parcel, Parcel::LABEL_FORMAT_A4_BOTTOM_RIGHT); | ||
|