Skip to content

Commit

Permalink
Update example in README
Browse files Browse the repository at this point in the history
  • Loading branch information
villermen committed Jul 4, 2023
1 parent 2b82a52 commit 31052b1
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 31052b1

Please sign in to comment.