Wiki source code of Current Promotion

Last modified by Shop Team on 2023/02/13 22:56

Show last authors
1 In order to display a promotion banner and let your customers benefit from promotional discounts, you can use the following resource. Ideally, the resource is fetched when a customer visits your site and we recommend to cache the response for 30min. To redeem a coupon code, append a URL parameter "&couponCode=<code>" to the checkout URL that you redirect your customers to. The discounts will then be visible in the checkout UI.
2
3 All requests to the **Public Shop API** should be made from your server and not from the browser. This allows you to leverage caching, avoids [[CORS>>url:https://en.wikipedia.org/wiki/Cross-origin_resource_sharing||rel="nofollow" shape="rect" class="external-link"]] policy interference and keeps your API key secure.
4
5 \\
6
7 |=(((
8 Method
9 )))|=(((
10 URL
11 )))|=(((
12 Example
13 )))
14 |(((
15 GET
16 )))|(((
17 {{{/api/v1/shops/&#x3c;shopId&#x3e;/currentPromotion}}}
18 )))|(((
19 [[https:~~/~~/api.spreadshirt.net/api/v1/shops/100488332/currentPromotion>>url:https://api.spreadshirt.net/api/v1/shops/100488332/currentPromotion||shape="rect"]]
20 )))
21
22 \\
23
24 Returns HTTP 404 if there is no promotion running at the time of the request. Otherwise, HTTP 200 is returned with a payload like this:
25
26 {{code language="js" title="Response Payload"}}
27 {
28 "description": "5% off everything",
29 "validUntil": "2019-10-29T23:59:59",
30 "code": "88S1C3S73E"
31 }
32 {{/code}}
33
34 \\
35
36 |=(((
37 Field
38 )))|=(((
39 Description
40 )))
41 |(((
42 description
43 )))|(((
44 A human-readable promotion text in the shop's language. Show this to the customer.
45 )))
46 |(((
47 validUntil
48 )))|(((
49 The last point in time when the current promotion is still valid. This timestamp is formatted according to ISO-8601 and always **implicitly in UTC**.
50 )))
51 |(((
52 code
53 )))|(((
54 The coupon code that can be used to redeem the current promotion (see paragraph above).
55 )))
56
57 \\