Search.../

getPackingSlipLink( )

Generates a link to a PDF file containing an order's packing slip.

Description

The getPackingSlipLink() function returns a Promise that resolves to an object containing the URL of a PDF file with the specified order's packing slip.

Syntax

function getPackingSlipLink(orderId: string): Promise<LinkToPdf>

getPackingSlipLink Parameters

NAME
TYPE
DESCRIPTION
orderId

string

ID of the order for which to generate a packing slip.

Returns

Fulfilled - URL to a PDF file. Rejected - Error message.

Return Type:

Promise<LinkToPdf>
NAME
TYPE
DESCRIPTION
link

string

URL to a PDF file.

Related Content:

Was this helpful?

Get a PDF file containing an order's packing slip

Code Example

Copy Code
1/*****************************
2 * Backend code - orders.jsw *
3 *****************************/
4
5import wixStoresBackend from 'wix-stores-backend';
6import wixData from 'wix-data';
7
8export function getPackingSlipLink(orderId) {
9 return wixStoresBackend.getPackingSlipLink(orderId);
10}
11
12// Get the most recent order's ID
13export function getLatestOrderId() {
14 let options = {
15 "suppressAuth": true
16 };
17
18 return wixData.query('Stores/Orders')
19 .descending('_dateCreated')
20 .limit(1)
21 .find(options)
22 .then((results) => {
23 if (results.items.length > 0) {
24 // Order ID found
25 return results.items[0]._id;
26 } else {
27 return "No orders found";
28 }
29 })
30 .catch((error) => {
31 return error;
32 })
33}
34
35
36/**************
37 * Page code *
38 **************/
39
40import { getPackingSlipLink, getLatestOrderId } from 'backend/orders';
41
42getLatestOrderId()
43 .then((orderId) => {
44 getPackingSlipLink(orderId)
45 .then((link) => {
46 // Packing slip PDF link retrieved
47 const packingSlipUrl = link;
48 })
49 .catch((error) => {
50 // Packing slip PDF link not retrieved
51 console.error(error)
52 })
53 })
54 .catch((error) => {
55 // Orders not retrieved from backend
56 console.error(error)
57 });
58
59/* Example packingSlipUrl:
60*
61* {
62* link: "https://wixmp-2a4e9...a5977f91b.appspot.com/_api/download/file?downloadToken=eyJ...jwAc"
63* }
64*
65*/
Get a PDF file with an order packing slip from the Thank You Page

Code Example

Copy Code
1/*****************************
2 * Backend code - orders.jsw *
3 *****************************/
4
5import wixStoresBackend from 'wix-stores-backend';
6
7export function getPackingSlipLink(orderId) {
8 return wixStoresBackend.getPackingSlipLink(orderId);
9}
10
11
12/**************
13 * Page code *
14 **************/
15
16import { getPackingSlipLink } from 'backend/orders';
17
18export function buttonPrintPackingSlip_click(event) {
19 $w('#myThankYouPage').getOrder()
20 .then((order) => {
21 getPackingSlipLink(order._id)
22 .then((url) => {
23 const packingSlipUrl = url;
24 })
25 .catch((error) => {
26 console.log(error);
27 });
28 });
29}
30
31/* Example packingSlipUrl:
32*
33* {
34* link: "https://wixmp-2a4e9...a5977f91b.appspot.com/_api/download/file?downloadToken=eyJ...jwAc"
35* }
36*
37*/