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 *****************************/45import wixStoresBackend from 'wix-stores-backend';6import wixData from 'wix-data';78export function getPackingSlipLink(orderId) {9 return wixStoresBackend.getPackingSlipLink(orderId);10}1112// Get the most recent order's ID13export function getLatestOrderId() {14 let options = {15 "suppressAuth": true16 };1718 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 found25 return results.items[0]._id;26 } else {27 return "No orders found";28 }29 })30 .catch((error) => {31 return error;32 })33}3435/**************36 * Page code *37 **************/3839import { getPackingSlipLink, getLatestOrderId } from 'backend/orders';4041getLatestOrderId()42 .then((orderId) => {43 getPackingSlipLink(orderId)44 .then((link) => {45 // Packing slip PDF link retrieved46 const packingSlipUrl = link;47 })48 .catch((error) => {49 // Packing slip PDF link not retrieved50 console.error(error)51 })52 })53 .catch((error) => {54 // Orders not retrieved from backend55 console.error(error)56 });5758/* 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 *****************************/45import wixStoresBackend from 'wix-stores-backend';67export function getPackingSlipLink(orderId) {8 return wixStoresBackend.getPackingSlipLink(orderId);9}1011/**************12 * Page code *13 **************/1415import { getPackingSlipLink } from 'backend/orders';1617export 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}2930/* Example packingSlipUrl:31*32* {33* link: "https://wixmp-2a4e9...a5977f91b.appspot.com/_api/download/file?downloadToken=eyJ...jwAc"34* }35*36*/