Wiki source code of Baskets

Version 2.1 by Shop Team on 2019/08/01 11:21

Show last authors
1 (% class="auto-cursor-target" %)
2 = Create a basket =
3
4 |=(((
5 Method
6 )))|=(((
7 URL
8 )))|=(((
9 Example
10 )))
11 |(((
12 POST
13 )))|(((
14 /api/v1/baskets
15 )))|(((
16 [[https:~~/~~/api.spreadshirt.net/api/v1/baskets?mediaType=json>>url:https://api.spreadshirt.net/api/v1/currencies/1?mediaType=json||shape="rect"]]
17 )))
18
19 Send a payload as shown below in the request body to create a new basket with any number of basket items in it. A request like this should usually be performed once a new customer interacts with the add-to-basket button for the first time while on your site.
20
21 {{code language="js" title="Example Payload"}}
22 {
23 "basketItems" :
24 [
25 {
26 "quantity" : 1,
27 "element" :
28 {
29 "id" : "praawgg73zU5gzZN0gaM-812-7",
30 "type" : "sprd:sellable",
31 "properties" :
32 [
33 {
34 "key" : "size",
35 "value" : "3"
36 },
37 {
38 "key" : "appearance",
39 "value" : "2"
40 }
41 ],
42 "shop" :
43 {
44 "id" : "100488332"
45 }
46 }
47 }
48 ]
49 }
50 {{/code}}
51
52 \\
53
54 |=(((
55 Field
56 )))|=(((
57 Description
58 )))
59 |(((
60 basketItems
61 )))|(((
62 An array that can contain 0-n entries.
63 )))
64 |(((
65 basketItems/quantity
66 )))|(((
67 The quantity of the specific basket item that the customer selected.
68 )))
69 |(((
70 basketItems/type
71 )))|(((
72 A constant for all Partner Area based shops. Always use "sprd:sellable".
73 )))
74 |(((
75 basketItems/properties
76 )))|(((
77 This array of key-value-pairs must always contain values for "size" and "appearance".
78 )))
79 |(% colspan="1" %)(% colspan="1" %)
80 (((
81 basketItems/shop/id
82 )))|(% colspan="1" %)(% colspan="1" %)
83 (((
84 The id of your shop.
85 )))
86
87 A successful request is answered with HTTP status code 201 and a response payload looking like this:
88
89 {{code language="js" title="Response Payload"}}
90 {
91 "href": "https://api.spreadshirt.net/api/v1/baskets/5ad33740-30ad-41b0-846f-9e1f0c6824b5",
92 "id": "5ad33740-30ad-41b0-846f-9e1f0c6824b5"
93 }
94 {{/code}}
95
96 The value of the "id" field should then be remembered in the customer's session because it allows to read or update the same basket as described next.
97
98 (% class="auto-cursor-target" %)
99 \\