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

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 * Page code *
37 **************/
38
39import { getPackingSlipLink, getLatestOrderId } from 'backend/orders';
40
41getLatestOrderId()
42 .then((orderId) => {
43 getPackingSlipLink(orderId)
44 .then((link) => {
45 // Packing slip PDF link retrieved
46 const packingSlipUrl = link;
47 })
48 .catch((error) => {
49 // Packing slip PDF link not retrieved
50 console.error(error)
51 })
52 })
53 .catch((error) => {
54 // Orders not retrieved from backend
55 console.error(error)
56 });
57
58/* Example packingSlipUrl:
59*
60* {
61* link: "https://wixmp-2a4e9...a5977f91b.appspot.com/_api/download/file?downloadToken=eyJ...jwAc"
62* }
63*
64*/
Get a PDF file with an order packing slip from the Thank You Page

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 * Page code *
13 **************/
14
15import { getPackingSlipLink } from 'backend/orders';
16
17export function buttonPrintPackingSlip_click(event) {
18 $w('#myThankYouPage').getOrder()
19 .then((order) => {
20 getPackingSlipLink(order._id)
21 .then((url) => {
22 const packingSlipUrl = url;
23 })
24 .catch((error) => {
25 console.log(error);
26 });
27 });
28}
29
30/* Example packingSlipUrl:
31*
32* {
33* link: "https://wixmp-2a4e9...a5977f91b.appspot.com/_api/download/file?downloadToken=eyJ...jwAc"
34* }
35*
36*/