Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 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 | |(% colspan="1" %)(% colspan="1" %) | ||
| 70 | ((( | ||
| 71 | basketItems/element/id | ||
| 72 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 73 | ((( | ||
| 74 | SellableId of the sellable you want to put into the basket. | ||
| 75 | ))) | ||
| 76 | |((( | ||
| 77 | basketItems/element/type | ||
| 78 | )))|((( | ||
| 79 | A constant for all Partner Area based shops. Always use "sprd:sellable". | ||
| 80 | ))) | ||
| 81 | |((( | ||
| 82 | basketItems/element/properties | ||
| 83 | )))|((( | ||
| 84 | This array of key-value-pairs must always contain values for "size" and "appearance". | ||
| 85 | ))) | ||
| 86 | |(% colspan="1" %)(% colspan="1" %) | ||
| 87 | ((( | ||
| 88 | basketItems/element/shop/id | ||
| 89 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 90 | ((( | ||
| 91 | The id of your shop. | ||
| 92 | ))) | ||
| 93 | |||
| 94 | A successful request is answered with HTTP status code 201 and a response payload looking like this: | ||
| 95 | |||
| 96 | {{code language="js" title="Response Payload"}} | ||
| 97 | { | ||
| 98 | "href": "https://api.spreadshirt.net/api/v1/baskets/5ad33740-30ad-41b0-846f-9e1f0c6824b5", | ||
| 99 | "id": "5ad33740-30ad-41b0-846f-9e1f0c6824b5" | ||
| 100 | } | ||
| 101 | {{/code}} | ||
| 102 | |||
| 103 | 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. | ||
| 104 | |||
| 105 | (% class="auto-cursor-target" %) | ||
| 106 | \\ | ||
| 107 | |||
| 108 | (% class="auto-cursor-target" %) | ||
| 109 | = Read a basket = | ||
| 110 | |||
| 111 | |=((( | ||
| 112 | Method | ||
| 113 | )))|=((( | ||
| 114 | URL | ||
| 115 | )))|=((( | ||
| 116 | Example | ||
| 117 | ))) | ||
| 118 | |((( | ||
| 119 | GET | ||
| 120 | )))|((( | ||
| 121 | /api/v1/baskets/<basketId> | ||
| 122 | )))|((( | ||
| 123 | [[https:~~/~~/api.spreadshirt.net/api/v1/baskets/5ad33740-30ad-41b0-846f-9e1f0c6824b5?mediaType=json>>url:https://api.spreadshirt.net/api/v1/currencies/1?mediaType=json||shape="rect"]] | ||
| 124 | ))) | ||
| 125 | |||
| 126 | (% class="auto-cursor-target" %) | ||
| 127 | Given an id obtained from creating a basket, this resource allows to read the basket data and it contains additional information that can be useful to show to the customer. | ||
| 128 | |||
| 129 | {{code language="js" title="Example Response Payload"}} | ||
| 130 | |||
| 131 | { | ||
| 132 | "href" : "https://api.spreadshirt.net/api/v1/baskets/5ad33740-30ad-41b0-846f-9e1f0c6824b5", | ||
| 133 | "id" : "5ad33740-30ad-41b0-846f-9e1f0c6824b5", | ||
| 134 | "shop" : | ||
| 135 | { | ||
| 136 | "href" : "https://api.spreadshirt.net/api/v1/shops/100488332", | ||
| 137 | "id" : "100488332" | ||
| 138 | }, | ||
| 139 | "currency" : | ||
| 140 | { | ||
| 141 | "href" : "https://api.spreadshirt.net/api/v1/currencies/1", | ||
| 142 | "id" : "1" | ||
| 143 | }, | ||
| 144 | "language" : | ||
| 145 | { | ||
| 146 | "href" : "https://api.spreadshirt.net/api/v1/languages/2", | ||
| 147 | "id" : "2" | ||
| 148 | }, | ||
| 149 | "country" : | ||
| 150 | { | ||
| 151 | "href" : "https://api.spreadshirt.net/api/v1/countries/1", | ||
| 152 | "id" : "1" | ||
| 153 | }, | ||
| 154 | "shipping" : | ||
| 155 | { | ||
| 156 | "price" : | ||
| 157 | { | ||
| 158 | "vatExcluded" : 4.16, | ||
| 159 | "vatIncluded" : 4.99, | ||
| 160 | "display" : 4.99, | ||
| 161 | "vat" : 20, | ||
| 162 | "currency" : | ||
| 163 | { | ||
| 164 | "href" : "https://api.spreadshirt.net/api/v1/currencies/1", | ||
| 165 | "id" : "1" | ||
| 166 | } | ||
| 167 | }, | ||
| 168 | "priceItem" : | ||
| 169 | { | ||
| 170 | "vatExcluded" : 4.16, | ||
| 171 | "vatIncluded" : 4.99, | ||
| 172 | "display" : 4.99, | ||
| 173 | "vat" : 20, | ||
| 174 | "currency" : | ||
| 175 | { | ||
| 176 | "href" : "https://api.spreadshirt.net/api/v1/currencies/1", | ||
| 177 | "id" : "1" | ||
| 178 | } | ||
| 179 | } | ||
| 180 | }, | ||
| 181 | "priceItems" : | ||
| 182 | { | ||
| 183 | "vatExcluded" : 14.58, | ||
| 184 | "vatIncluded" : 17.49, | ||
| 185 | "display" : 17.49, | ||
| 186 | "currency" : | ||
| 187 | { | ||
| 188 | "href" : "https://api.spreadshirt.net/api/v1/currencies/1", | ||
| 189 | "id" : "1" | ||
| 190 | } | ||
| 191 | }, | ||
| 192 | "priceTotal" : | ||
| 193 | { | ||
| 194 | "vatExcluded" : 18.74, | ||
| 195 | "vatIncluded" : 22.48, | ||
| 196 | "display" : 22.48, | ||
| 197 | "currency" : | ||
| 198 | { | ||
| 199 | "href" : "https://api.spreadshirt.net/api/v1/currencies/1", | ||
| 200 | "id" : "1" | ||
| 201 | } | ||
| 202 | }, | ||
| 203 | "basketItems" : | ||
| 204 | [ | ||
| 205 | { | ||
| 206 | "href" : "https://api.spreadshirt.net/api/v1/baskets/5ad33740-30ad-41b0-846f-9e1f0c6824b5/items/672b26f1-e9e5-479b-973a-cfba1d1c8139", | ||
| 207 | "id" : "672b26f1-e9e5-479b-973a-cfba1d1c8139", | ||
| 208 | "description" : "Men’s Premium T-Shirt", | ||
| 209 | "quantity" : 1, | ||
| 210 | "element" : | ||
| 211 | { | ||
| 212 | "id" : "praawgg73zU5gzZN0gaM-812-7", | ||
| 213 | "type" : "sprd:sellable", | ||
| 214 | "shop" : | ||
| 215 | { | ||
| 216 | "href" : "https://api.spreadshirt.net/api/v1/shops/100488332", | ||
| 217 | "id" : "100488332" | ||
| 218 | }, | ||
| 219 | "properties" : | ||
| 220 | [ | ||
| 221 | { | ||
| 222 | "key" : "size", | ||
| 223 | "value" : "3" | ||
| 224 | }, | ||
| 225 | { | ||
| 226 | "key" : "sizeLabel", | ||
| 227 | "value" : "M" | ||
| 228 | }, | ||
| 229 | { | ||
| 230 | "key" : "appearance", | ||
| 231 | "value" : "2" | ||
| 232 | }, | ||
| 233 | { | ||
| 234 | "key" : "appearanceLabel", | ||
| 235 | "value" : "black" | ||
| 236 | }, | ||
| 237 | { | ||
| 238 | "key" : "sellable", | ||
| 239 | "value" : "praawgg73zU5gzZN0gaM-812-7" | ||
| 240 | }, | ||
| 241 | { | ||
| 242 | "key" : "idea", | ||
| 243 | "value" : "5d22f8ebb264a16f6b87fb6f" | ||
| 244 | }, | ||
| 245 | { | ||
| 246 | "key" : "product", | ||
| 247 | "value" : "524053687" | ||
| 248 | }, | ||
| 249 | { | ||
| 250 | "key" : "productType", | ||
| 251 | "value" : "812" | ||
| 252 | }, | ||
| 253 | { | ||
| 254 | "key" : "appearanceLink", | ||
| 255 | "value" : "http://image.spreadshirtmedia.net/image-server/v1/appearances/2" | ||
| 256 | } | ||
| 257 | ] | ||
| 258 | }, | ||
| 259 | "shop" : | ||
| 260 | { | ||
| 261 | "href" : "https://api.spreadshirt.net/api/v1/shops/100488332", | ||
| 262 | "id" : "100488332" | ||
| 263 | }, | ||
| 264 | "priceItem" : | ||
| 265 | { | ||
| 266 | "vatExcluded" : 14.58, | ||
| 267 | "vatIncluded" : 17.49, | ||
| 268 | "display" : 17.49, | ||
| 269 | "vat" : 20, | ||
| 270 | "currency" : | ||
| 271 | { | ||
| 272 | "href" : "https://api.spreadshirt.net/api/v1/currencies/1", | ||
| 273 | "id" : "1" | ||
| 274 | } | ||
| 275 | }, | ||
| 276 | "price" : | ||
| 277 | { | ||
| 278 | "vatExcluded" : 14.58, | ||
| 279 | "vatIncluded" : 17.49, | ||
| 280 | "display" : 17.49, | ||
| 281 | "vat" : 20, | ||
| 282 | "currency" : | ||
| 283 | { | ||
| 284 | "href" : "https://api.spreadshirt.net/api/v1/currencies/1", | ||
| 285 | "id" : "1" | ||
| 286 | } | ||
| 287 | } | ||
| 288 | } | ||
| 289 | ], | ||
| 290 | "links" : | ||
| 291 | [ | ||
| 292 | { | ||
| 293 | "type" : "defaultCheckout", | ||
| 294 | "href" : "https://checkout.spreadshirt.de/en?basketId=5ad33740-30ad-41b0-846f-9e1f0c6824b5" | ||
| 295 | }, | ||
| 296 | { | ||
| 297 | "type" : "shopCheckout", | ||
| 298 | "href" : "https://checkout.spreadshirt.de/en?basketId=5ad33740-30ad-41b0-846f-9e1f0c6824b5&shopId=100488332" | ||
| 299 | }, | ||
| 300 | { | ||
| 301 | "type" : "platformCheckout", | ||
| 302 | "href" : "https://checkout.spreadshirt.de/en?basketId=5ad33740-30ad-41b0-846f-9e1f0c6824b5" | ||
| 303 | } | ||
| 304 | ] | ||
| 305 | } | ||
| 306 | {{/code}} | ||
| 307 | |||
| 308 | The most important fields are summarized as follows: | ||
| 309 | |||
| 310 | |=((( | ||
| 311 | Field | ||
| 312 | )))|=((( | ||
| 313 | Description | ||
| 314 | ))) | ||
| 315 | |((( | ||
| 316 | shipping/priceItem/display | ||
| 317 | )))|((( | ||
| 318 | Assumed shipping price for standard shipping without shipping discounts. (The exact price depends on the customer's location.) | ||
| 319 | ))) | ||
| 320 | |((( | ||
| 321 | shipping/price/display | ||
| 322 | )))|((( | ||
| 323 | Assumed shipping price for standard shipping with shipping discounts subtracted. (The exact price depends on the customer's location.) | ||
| 324 | ))) | ||
| 325 | |((( | ||
| 326 | priceItems/display | ||
| 327 | )))|((( | ||
| 328 | Total price of all basket items with discounts already subtracted. | ||
| 329 | ))) | ||
| 330 | |((( | ||
| 331 | priceTotal/display | ||
| 332 | )))|((( | ||
| 333 | Total price of all basket items (with discounts already subtracted) plus shipping/price/display. This is what you usually want to dispay as **total**. | ||
| 334 | ))) | ||
| 335 | |((( | ||
| 336 | basketItems/description | ||
| 337 | )))|((( | ||
| 338 | Human-readable product type description. | ||
| 339 | ))) | ||
| 340 | |((( | ||
| 341 | basketItems/quantity | ||
| 342 | )))|((( | ||
| 343 | This is what you sent when creating the basket. | ||
| 344 | ))) | ||
| 345 | |((( | ||
| 346 | basketItems/element/id | ||
| 347 | )))|((( | ||
| 348 | This is what you sent when creating the basket. | ||
| 349 | ))) | ||
| 350 | |((( | ||
| 351 | basketItems/element/properties | ||
| 352 | )))|((( | ||
| 353 | Aside from the properties that you sent yourself when creating the basket, this also includes the useful human-readable fields "sizeLabel" and "appearanceLabel". | ||
| 354 | ))) | ||
| 355 | |(% colspan="1" %)(% colspan="1" %) | ||
| 356 | ((( | ||
| 357 | basketItems/priceItem/display | ||
| 358 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 359 | ((( | ||
| 360 | The price for an item with quantity=1 without taking discounts into account. | ||
| 361 | ))) | ||
| 362 | |(% colspan="1" %)(% colspan="1" %) | ||
| 363 | ((( | ||
| 364 | basketItems/price/display | ||
| 365 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 366 | ((( | ||
| 367 | The price for an item with quantity=1 with discounts subtracted. | ||
| 368 | ))) | ||
| 369 | |(% colspan="1" %)(% colspan="1" %) | ||
| 370 | ((( | ||
| 371 | links | ||
| 372 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 373 | ((( | ||
| 374 | Use the link with type "shopCheckout" to redirect your customer to Spreadshirt's checkout. | ||
| 375 | ))) | ||
| 376 | |||
| 377 | \\ |