Search.../

createPriceQuote( )

Creates a new price quote.

Description

The createPriceQuote() function returns a Promise that resolves to the created price quote's ID and version when the price quote is created.

Note: The customer ID and email address listed on the price quote must match an existing contact in the site's contact list.

Syntax

function createPriceQuote(priceQuoteInfo: PriceQuoteInfo): Promise<Response>

createPriceQuote Parameters

NAME
TYPE
DESCRIPTION
priceQuoteInfo
PriceQuoteInfo

The data used to create a price quote.

Returns

Fulfilled - ID and version of the created price quote.

Return Type:

Promise<Response>
NAME
TYPE
DESCRIPTION
id
IdAndVersion

ID and version information.

Was this helpful?

Create a new price quote

Copy Code
1import {priceQuotes} from 'wix-billing-backend';
2
3const now = new Date()
4const dueDate = new Date()
5dueDate.setDate(now.getDate() + 30)
6
7let customer = {
8 // contact ID and email address must match an
9 // existing contact in the site's contact list
10 "contactId": "4f7c6637-0657-4696-a00b-9bc2ae4e035d",
11 "email": "john.doe@somedomain.com",
12 "address": {
13 "city": "New York",
14 "subdivision": "NY",
15 "postalCode": "10011",
16 "country": "USA",
17 "addressLine": "235 W 23rd St"
18 },
19 "billingAddress": {
20 "country": "USA",
21 "streetAddress": {
22 "value": "235 W 23rd St",
23 "type": "Name"
24 },
25 "addressLine": "235 W 23rd St, New York, NY 10011, USA",
26 "addressLine2": "secondary address",
27 "postalCode": "10011",
28 "subdivision": "NY",
29 "city": "New York"
30 },
31 "shippingAddress": {
32 "country": "USA",
33 "streetAddress": {
34 "value": "235 W 23rd St",
35 "type": "Name"
36 },
37 "addressLine": "235 W 23rd St, New York, NY 10011, USA",
38 "addressLine2": "secondary address",
39 "postalCode": "10011",
40 "subdivision": "NY",
41 "city": "New York"
42 },
43 "phone": "5555555555",
44 "company": "Some Company",
45 "companyId": "Some Company Id",
46 "fullName": "John Doe",
47 "firstName": "John",
48 "lastName": "Doe"
49};
50
51let lineItems = [
52 {
53 "id": "00001",
54 "name": "Item 1",
55 "description": "First Item",
56 "price": 10.50,
57 "quantity": 3,
58 "taxes": [{
59 "name": "tax name",
60 "rate": 8.5,
61 "code": "tax code"
62 }]
63 },
64 {
65 "id": "00002",
66 "name": "Item 2",
67 "description": "Second Item",
68 "price": 50,
69 "quantity": 1,
70 "taxes": [{
71 "name": "tax name",
72 "rate": 8.5,
73 "code": "tax code"
74 }]
75 }
76];
77
78let discount = {
79 "value": 2.5,
80 "type": "Fixed"
81};
82
83let paymentTerms = {
84 "termData": "some term data",
85 "termType": "DueOnReceipt"
86};
87
88let metadata = {
89 "notes": "Some note.",
90 "legalTerms": "Some legal terms",
91 "sourceUrl": "http://legalurl.com",
92 "source": "Some source",
93 "sourceRefId": "Some source ref id"
94};
95
96let dates = {
97 "issueDate": now,
98 "validThroughDate": dueDate
99};
100
101export function createPriceQuote() {
102 let createPriceQuoteFields = {
103 "title": "My Price Quote",
104 "customer": customer,
105 "currency": "USD",
106 "lineItems": lineItems,
107 "discount": discount,
108 "paymentTerms": paymentTerms,
109 "metadata": metadata,
110 "dates": dates
111 };
112
113 return priceQuotes.createPriceQuote(createPriceQuoteFields);
114}
115
116/* Promise resolves to:
117 * {
118 * "id": {
119 * "id": "411a5551-b0f6-4826-8a41-ebae2879f857"
120 * "version": 25
121 * }
122 * }
123*/