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.

Authorization

Request

This endpoint does not take any parameters

Response Object

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

NAME
TYPE
DESCRIPTION
link
string

URL to a PDF file.

Status/Error Codes

Related Content:

Was this helpful?

Get a PDF file containing information about paid orders

Copy Code
1/*****************************
2 * Backend code - orders.jsw *
3 *****************************/
4
5import wixStoresBackend from 'wix-stores-backend';
6import wixData from 'wix-data';
7
8export function getOrdersLink(orderIds) {
9 return wixStoresBackend.getOrdersLink(orderIds);
10}
11
12// Get IDs of the last 10 paid orders
13export function getPaidOrderIds() {
14 let options = {
15 "suppressAuth": true
16 };
17
18 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 found
26 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}
36
37/**************
38 * Page code *
39 **************/
40
41import { getOrdersLink, getPaidOrderIds } from 'backend/orders';
42
43getPaidOrderIds()
44 .then((orderIds) => {
45 getOrdersLink(orderIds)
46 .then((link) => {
47 // Orders PDF link retrieved
48 const orderPdfUrl = link;
49 })
50 .catch((error) => {
51 // Orders PDF link not retrieved
52 console.error(error)
53 })
54 })
55 .catch((error) => {
56 // Orders not retrieved from backend
57 console.error(error)
58 });
59
60/* 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 *****************************/
4
5import wixStoresBackend from 'wix-stores-backend';
6
7export function getOrdersLink(orderIds) {
8 return wixStoresBackend.getOrdersLink(orderIds);
9}
10
11/**************
12 * Page code *
13 **************/
14
15import { getOrdersLink } from 'backend/orders';
16
17export 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}
29
30/* Example orderPdfUrl:
31*
32* {
33* link: "https://wixmp-2a4e9...a5977f91b.appspot.com/_api/download/file?downloadToken=E43f...QiOns"
34* }
35*
36*/