Before we start you can take a look at a working (minimal) example that we have built in order to demonstrate the capabilities of the Public Shop API: https://github.com/spreadshirt/shop-api-example-integration. It . It shows a draft of a shop system written in php that might be helpful to understand the (list-page -> detail-page -> add-to-basket) workflow.
The following topics will not be covered by this tutorial and will be treated as given:
- A Spreadshop with one or more design ideas which you configured in the PartnerAreaPartner Area
- An Spreadshirt API Key
HTML and CSS knowledge
Basic understanding about HTTP and "REST Resources" (in combination often called API)
A solid understanding of HTTP, HTML, CSS, client-side and server-side programming.
Step by step
1. Manage your assets in the Partner Area
After you have created your Spreadshop you are ready to manage your assets at any time in the Partner Area. This is the only supported way to manage your shops, designs and products.
Product data import
The There are no endpoints available that allow uploading or changing the content of your shop. Use the partner area to upload designs and manage your assortment. Note that not only the content you upload in the Partner Area, but also the shop settings affect the output of the sellable resources. For example, enabling model images affects the image URLs returned by the API.
2. Build a scheduled sellable data import
To use the full potential of a custom shop implementation it is recommended to import all data the entries of the sellable list resource into your own database . It might be possible to use every 24 hours. The example integration uses the Public Shop API as a direct data source for your shop but the feature set is small and performance will suffer. For example, you would not be able simplicity, but that is not the recommended approach. The import based solution yields better performance and allows you to introduce all kinds of filtering and sorting options because these (which are NOT built into the Public Shop API. That means that you should fetch (periodically or on demand) all sellables via the Public Shop API and import them to YOUR database. Once you have imported this data you can build a frontend that meets your requirements. The only thing that should require direct API access based on customer action is the Basket API.
- Product Type based navigation can be built using ProductType Departments and Categories
- For localization see Country, Language and Currency (also see Price Formatting Guide)
- If you want to display correct shipping information you should study the Shipping Types documentation
There is no Public API available for uploading or updating ideas or sellables. This should be done via the Partner Area.
Note that not only the content you upload in the Partner Area, but also the shop settings affect the output of the sellable resources. For example, enabling model images affects the image URLs returned by the API.
Basket handling and checkout
Please see the baskets resource documentation on how to create and update Spreadshirt API Baskets. It is up to you if you directly use the Spreadshirt Baskets API for your shop or if you create one on checkout and use your own basket implementation.
3. Build the list page
Using the sellable data from your data base, you can now build your own list page giving an overview over the available sellables. Use the "previewImage.url" field directly in your <img> tags. You are free to build any navigational structure and filtering mechanisms you deem necessary. Depending on your needs, the ProductType Departments and Categories resource might be useful.
4. Build the detail page
When assembling a detail page on your server, request the sellable detail resource allowing you to render all available images as well as sizes. If you want to display things like name and description of the product type, appearance names and colors, etc., the ProductType resource is useful. The response of that resource is slow and rarely changes, so it is a good candidate for caching. In a somewhat generic implementation, the Price Formatting Guide might be helpful.
5. Build a basket
Once a user clicks the add-to-basket button, use the "Create a basket" resource to create a Spreadshirt basket with the selected sellable in it. Associate the returned basket id with the customer's session. You can now use the fields from the basket payload to assemble a drop-down UI component or something similar. Use the "Update a basket" resource for subsequent customer interactions.
6. Redirect to the Spreadshirt checkout
Finally, you can redirect the customer to the Spreadshirt checkout using the "shop checkout" link from the basket response. We will take over from there.