Create a basket
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.
|basketItems||An array that can contain 0-n entries.|
|basketItems/quantity||The quantity of the specific basket item that the customer selected.|
|basketItems/element/id||SellableId of the sellable you want to put into the basket.|
|basketItems/element/type||A constant for all Partner Area based shops. Always use "sprd:sellable".|
|basketItems/element/properties||This array of key-value-pairs must always contain values for "size" and "appearance".|
|basketItems/element/shop/id||The id of your shop.|
A successful request is answered with HTTP status code 201 and a response payload looking like this:
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.
Retrieve a basket
|locale||Use on of the values described here. This will affect the assumed shipping costs as well as the localized names of "description", "sizeLabel" and "appearanceLabel".|
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.
The most important fields are summarized as follows:
|shipping/priceItem/display||Assumed shipping price for standard shipping without shipping discounts. (The exact price depends on the customer's location.)|
|shipping/price/display||Assumed shipping price for standard shipping with shipping discounts subtracted. (The exact price depends on the customer's location.)|
|priceItems/display||Total price of all basket items with discounts already subtracted.|
|priceTotal/display||Total price of all basket items (with discounts already subtracted) plus shipping/price/display. This is what you usually want to dispay as total.|
|basketItems/description||Human-readable product type description. Depends on the locale parameter.|
|basketItems/quantity||This is what you sent when creating the basket.|
|basketItems/element/id||This is what you sent when creating the basket.|
|basketItems/element/properties||Aside from the properties that you sent yourself when creating the basket, this also includes the useful human-readable fields "sizeLabel" and "appearanceLabel". These depend on the locale parameter.|
|basketItems/priceItem/display||The price for an item with quantity=1 without taking discounts into account.|
|basketItems/price/display||The price for an item with quantity=1 with discounts subtracted.|
|links||Use the link with type "shopCheckout" to redirect your customer to Spreadshirt's checkout.|
Update a basket
Allows to update an existing basket by overwriting its content. This works as follows:
- Retrieve an existing basket via GET.
- Modify the response payload according to your needs.
- Send the modified payload via PUT.
- In the response body, the result of the update is returned. Save and display this response; an additional GET request is thus not required.
"Modifying the payload" might mean increasing or decreasing a basket item's quantity, adding or removing basket items from the "basketItems" array. Fields like prices can of course not be set by you. It is irrelevant whether you send them with the PUT request or not. However, you need to know how prices change when you increased an item's quantity - that is what the response body is for.