Search...
getOrdersLink( )
Generates a link to a PDF file containing information about one or more specified orders, up to 1000 orders.
Description
The getOrdersLink()
function returns a Promise that resolves to an object containing the URL of a PDF file with the specified orders' information, 1 order per page.
Syntax
function getOrdersLink(orderIds: Array<string>): Promise<LinkToPdf>
getOrdersLink Parameters
NAME
TYPE
DESCRIPTION
orderIds
Array<string>
IDs of the orders for which to generate a PDF file.
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 information about paid orders
Copy Code
1/*****************************2 * Backend code - orders.jsw *3 *****************************/45import wixStoresBackend from 'wix-stores-backend';6import wixData from 'wix-data';78export function getOrdersLink(orderIds) {9 return wixStoresBackend.getOrdersLink(orderIds);10}1112// Get IDs of the last 10 paid orders13export function getPaidOrderIds() {14 let options = {15 "suppressAuth": true16 };1718 return wixData.query('Stores/Orders')19 .eq("paymentStatus", 'PAID')20 .descending('_dateCreated')21 .limit(10)22 .find(options)23 .then((results) => {24 if (results.items.length > 0) {25 // Order IDs found26 const orderIds = results.items.map(order => order._id)27 return orderIds;28 } else {29 return "No orders found";30 }31 })32 .catch((error) => {33 return error;34 })35}3637/**************38 * Page code *39 **************/4041import { getOrdersLink, getPaidOrderIds } from 'backend/orders';4243getPaidOrderIds()44 .then((orderIds) => {45 getOrdersLink(orderIds)46 .then((link) => {47 // Orders PDF link retrieved48 const orderPdfUrl = link;49 })50 .catch((error) => {51 // Orders PDF link not retrieved52 console.error(error)53 })54 })55 .catch((error) => {56 // Orders not retrieved from backend57 console.error(error)58 });5960/* Example orderPdfUrl:61*62* {63* link: "https://wixmp-2a4e9...a5977f91b.appspot.com/_api/download/file?downloadToken=E43f...QiOns"64* }65*66*/
Get a PDF file with order information from the Thank You Page
Copy Code
1/*****************************2 * Backend code - orders.jsw *3 *****************************/45import wixStoresBackend from 'wix-stores-backend';67export function getOrdersLink(orderIds) {8 return wixStoresBackend.getOrdersLink(orderIds);9}1011/**************12 * Page code *13 **************/1415import { getOrdersLink } from 'backend/orders';1617export function buttonPrintOrder_click(event) {18 $w('#myThankYouPage').getOrder()19 .then((order) => {20 getOrdersLink([order._id])21 .then((url) => {22 const orderPdfUrl = url;23 })24 .catch((error) => {25 console.log(error);26 });27 });28}2930/* Example orderPdfUrl:31*32* {33* link: "https://wixmp-2a4e9...a5977f91b.appspot.com/_api/download/file?downloadToken=E43f...QiOns"34* }35*36*/