TLDR: Now that your Styla content is rendered on your website and requests are routed to it accordingly, Styla needs to integrate with product data from your shop application. In order to do this, you will need to make this data available either as a static file or a JSON API and provide a function or an endpoint to be called by Styla when a product is added to the card.
Styla clients usually provide the product data in one of the two ways described below. Building an API requires more effort but enables Styla to request the product data in real time and is a much better way to pass variant and price data for single products.
Provide an API that makes the product data from your shop application available via two endpoints described below. The field names and endpoint paths may be different as long as the data is there.
Name: | Type: | Comments: |
---|---|---|
id | String|Number |
|
name | String |
|
children | Array | each child category should include the: id, name, children nodes |
This endpoint will be used to: display category tree (structure) in backoffice.styla.com that editors of your Styla content will be able to browse or search and display products (using the category ID as a filter).
Example nodes:
[ { "id": "00001", "name": "Women", "children": [ { "id": "00010", "name": "Jeans", "children": [ { "id": "00100", "name": "Regular fit", "children": [] }, { "id": "00101", "name": "Straight fit", "children": [] }, { "id": "00102", "name": "Slim fit", "children": [] } ] }, { "id": "00011", "name": "T-shirts", "children": [] }, { "id": "00012", "name": "Scarves", "children": [] } ] }, { "id": "00002", "name": "Men", "children": [ { "id": "00013", "name": "Jeans", "children": [] } ] } ] ...
Name: | Type: | Comments: |
---|---|---|
id | String|Number |
|
caption | String |
|
image | String |
|
pageUrl | String |
|
Example nodes:
{ "id": "000000123456-AA", "caption": "Classic Blue Regular Fit Jeans", "image": [ "https://images.example.com/products/large/000000123456-aa-01.jpg", "https://images.example.com/products/large/000000123456-aa-02.jpg", "https://images.example.com/products/large/000000123456-aa-03.jpg", "https://images.example.com/products/large/000000123456-aa-04.jpg" ], "pageUrl": "https://www.example.com/us_en/products/classic-blue-regulard-fit-jeans/" }, { "id": "000000123478-AA", "caption": "Ripped Loose Fit Jeans", "image": [ "https://images.example.com/products/large/000000123478-aa-01.jpg", "https://images.example.com/products/large/000000123478-aa-02.jpg", "https://images.example.com/products/large/000000123478-aa-03.jpg", "https://images.example.com/products/large/000000123478-aa-04.jpg", "https://images.example.com/products/large/000000123478-aa-05.jpg", "https://images.example.com/products/large/000000123478-aa-06.jpg" ], "pageUrl": "https://www.example.com/us_en/products/ripped-regular-fit-jeans/" }, { "id": "000000123481-AA", "caption": "Super Stylish Regular Fit Jeans", "image": [ "https://images.example.com/products/large/000000123481-aa-01.jpg", "https://images.example.com/products/large/000000123481-aa-02.jpg" ], "pageUrl": "https://www.example.com/us_en/products/super-stylish-regular-fit-jeans/" } ]
Provide a file with product information that Styla needs to let your content editors add you products in the backoffice.styla.com and then display them on Styla front-end.
As for the file type itself, several options are possible:
Or any other format. The file just needs to:
Name: | Type: | Comments: |
---|---|---|
id | String|Number |
|
product_type | String |
|
title | String |
|
image_link | String |
|
link | String |
|
Field naming from Google Product Feed is used in the table above but names may be different as long as the data is there.
Styla will parse the file each 6 hours with its Product API and update the product data used by your editor.styla.com for any future stories. Images, product names and product URL that have been saved in any story won't be updated there.
Example structure 1:
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0"> <channel> <title>Google Shopping Feed</title> <link>http://www.example.com/api/products?format=xml</link> <description>Google Shopping Feed</description> <item> <g:id>000000123456-AA</g:id> <title><![CDATA[Classic Blue Regular Fit Jeans]]></title> <description><![CDATA[Classic yet laid-back. You'll love the feel of these men's jeans.]]> </description> <g:price>59 USD</g:price> <g:sale_price>39 USD</g:sale_price> <g:brand>Awesome Jeans</g:brand> <link>https://www.example.com/us_en/products/classic-blue-regular-fit-jeans/</link> <g:image_link>https://images.example.com/products/large/000000123456-aa-01.jpg</g:image_link> <g:product_type> <![CDATA[Women > Jeans > Regular fit]]> </g:product_type> </item> <item> <g:id>000000123478-AA</g:id> <title><![CDATA[Ripped Regular Fit Jeans]]></title> <description><![CDATA[Mid-rise. Three-pocket styling. Button-fly. 100% cotton. Made in the UK.]]> </description> <g:price>69 USD</g:price> <g:sale_price>49 USD</g:sale_price> <g:brand>Unique Jeans</g:brand> <link>https://www.example.com/us_en/products/ripped-regular-fit-jeans/</link> <g:image_link>https://images.example.com/products/large/000000123478-aa-01.jpg</g:image_link> <g:product_type> <![CDATA[Women > Jeans > Loose fit]]> </g:product_type> </item> </channel> ... </rss>
Example structure 2:
<product> <id>000000123456-AA</sku> <title>Classic Blue Regular Fit Jeans</name> <image_link>https://images.example.com/products/large/000000123456-aa-01.jpg</image_link> <link>https://www.example.com/us_en/products/classic-blue-regular-fit-jeans/</link> <product_type>Women > Jeans > Regular fit</product_type> </product> <product> <id>000000123478-AA</sku> <title>Ripped Regular Fit Jeans</name> <image_link>https://images.example.com/products/large/000000123478-aa-01.jpg</image_link> <link>https://www.example.com/us_en/products/ripped-regular-fit-jeans/</link> <product_type>Women > Jeans > Regular fit</product_type> </product> ... </xml>
Example structure 3:
id|product_type|title|image_link|link "000000123456-AA" | "Classic Blue Regular Fit Jeans"|"https://images.example.com/products/large/000000123456-aa-01.jpg"|"https://www.example.com/us_en/products/classic-blue-regular-fit-jeans/"|"Women > Jeans > Regular fit" "000000123478-AA" | "Ripped Regular Fit Jeans"|"https://images.example.com/products/large/000000123478-aa-01.jpg"|"https://www.example.com/us_en/products/ripped-regular-fit-jeans/"|"Women > Jeans > Regular fit" ...
Providing data over a JSON API (the option A above) is a better choice since it lets Styla enabling the "Add to Cart" function since real-time availability for products is needed and it removes the delays between your static file is updated on your end and then crawled by Styla.
If you want to use Styla's "Add to Cart" functionality in your Styla content, you will need to provide a detailed data for each product variant and a way for Styla to call adding a product ID to the cart in your shop system.
Name: | Type: | Mandatory?: | Comments: |
---|---|---|---|
id | String|Number | Yes |
|
type | String | ? | ? |
name | String | Yes |
|
saleable | Boolean | Yes |
|
price | String|Number | Yes |
|
oldPrice | String|Number | No |
|
priceTemplate | String | No |
|
minqty | Number | No | a minimal quantity that can be added to the cart (usually: 1) |
maxqty | Number | No | a maximal quantity that can be added to the cart (usually: none) |
description | String | No | text description of the product to be displayed on Styla's shopping layer |
categories | Array | No | lists IDs of categories to which product belongs (they need to match IDs on the categories endpoint) |
brand | String | No | delivers brand name associated with product |
rating | Number (between 0 and 5) | No | A value based on which rating stars (full and halves) are rendered in Styla content. It gets rounded to halves by Styla automatically (so can be 1.3452 or 4.532).. |
attributes | Array | No | a set of variants of the "umbrella" product (example for a T-shirt: size, colour) |
id | String|Number | Yes |
|
label | String | Yes |
|
options | Array | No |
|
shippingStatus | String | No |
|
tax | Array | No | a set of additional tax-reated information to be displayed on the styla content next to the price |
rate | Number | No |
|
taxIncluded | Boolean | No |
|
showLabel | Boolean | No |
|
Label | String | No |
|
Example node:
{ "id": "000000123456-AA", "type": "configurable", "name": "Classic Blue Regular Fit Jeans", "saleable": true, "price": 39, "oldPrice": 59, "priceTemplate": "#{price} €", "minqty": 1, "maxqty": 100, "description": "These jeans will make you look great. They were designed in Paris and are produced from best environment-friendly materials.", "shippingStatus": "Ships in 5 work days", "tax": { "rate": 19.0, "taxIncluded": true, "showLabel": true, "label": "VAT tax included" }, "attributes": [ { "id": "SIZE", "label": "Size", "options": [ { "id": "SIZE-34-34", "label": "34-34", "products": [ { "id": "000000123456-AA-SIZE-34-34-BLUE", "saleable": true, "price": 39, "oldPrice": 59 } ], "id": "SIZE-34-32", "label": "34-32", "products": [ { "id": "000000123456-AA-SIZE-34-32-BLUE", "saleable": true, "price": 39, "oldPrice": 59 } ] }, { "id": "COLOUR", "label": "Colour", "options": [ { "id": "COLOUR-BLUE", "label": "Blue", "products": [ { "id": "000000123456-AA-SIZE-34-34-BLUE", "saleable": true, "price": 39, "oldPrice": 59 }, { "id": "000000123456-AA-SIZE-34-32-BLUE", "saleable": true, "price": 39, "oldPrice": 59 } ] } ] } ] } ] }, { "id": "000000123478-AA", "type": "configurable", "name": "Ripped Regular Fit Jeans", "saleable": true, "price": 49, "oldPrice": 69, "priceTemplate": "#{price} €", "minqty": 1, "maxqty": 20, "tax": { "rate": 19.0, "taxIncluded": true, "showLabel": true, "label": "VAT tax included" }, "attributes": [ { "id": "SIZE", "label": "Size", "options": [ { "id": "SIZE-30-30", "label": "30-30", "products": [ { "id": "000000123478-AA-30-30-blue", "saleable": true, "price": 49, "oldPrice": 69 }, { "id": "000000123478-AA-30-30-black", "saleable": true, "price": 49, "oldPrice": 69 } ], "id": "SIZE-32-32", "label": "32-32", "products": [ { "id": "000000123478-AA-32-32-blue", "saleable": true, "price": 49, "oldPrice": 69 }, { "id": "000000123478-AA-32-32-black", "saleable": true, "price": 49, "oldPrice": 69 } ] }, { "id": "COLOUR", "label": "Colour", "options": [ { "id": "COLOUR-BLUE", "label": "Blue", "products": [ { "id": "000000123478-AA-30-30-blue", "saleable": true, "price": 49, "oldPrice": 69 }, { "id": "000000123478-AA-32-32-blue", "saleable": true, "price": 49, "oldPrice": 69 } ], "id": "COLOUR-BLACK", "label": "Black", "products": [ { "id": "000000123478-AA-30-30-black", "saleable": true, "price": 69, "oldPrice": null }, { "id": "000000123478-AA-32-32-black", "saleable": true, "price": 69, "oldPrice": null } ] } ] } ] } ], }, { "id": "000000120121-AC", "type": "simple", "name": "A Really Nice Red T-Shirt Size M", "saleable": true, "price": "20", "oldPrice": null, "priceTemplate": "#{price} €", "minqty": 1, "maxqty": 100, "shippingStatus": "Ships in 5 work days", "tax": { "rate": 19.0, "taxIncluded": true, "showLabel": true, "label": "VAT tax included" }, "attributes": null }, ...
for any not found or faulty products, the endpoint should return:
{"error": "Product not found", "saleable": false}
There are two alternative ways for Styla to add products to the cart in your shop application. Both should:
Please provide Styla with either of the ways mentioned below, with a short description, if needed.
Styla can also trigger a callback function on your end if it's needed. To make this possible, please provide:
window.styla = window.styla || {callbacks:[]}; window.styla.callbacks.push({'updateCart':function(){...}});
Provide a function that adds a product variant id and quantity (optional), adds the product into the cart in your shop for Styla content is embedded on and triggers any front-end events that you need. This function should look like this:
window.styla = window.styla || {callbacks:[]}; window.styla.callbacks.push({'addToCart':function(productId,qty){...}}); You can also add any further logic related to the "Add to Cart" process, for instance displaying a custom confirmation overlay: window.styla = window.styla || {callbacks:[]}; window.styla.callbacks.push({'addToCart':function(productId,qty) { // Call here your add to cart logic return new Promise((resolve, reject) => { // ATC worked ... return resolve(); // ATC failed ... return reject(); }); }});
Styla will only execute the callback if it includes a promise, so please make sure to implement a promise. Also, please make sure to reject the promise if a given product cannot be added to your cart (for instance, if sold out).
If you need your products to be featured in your Content Hub, your product data has to be used by:
window.styla.callbacks[0].addToCart("sku", quantity)
Can be called from your console (example: window.styla.callbacks[0].addToCart("74255086-34-10024897949", 1)) at: https://www.ackermann.ch/inspiration/mein-magazin/ which displays the Styla content using the product data fromt he client's endpoints.
This is an example of a hybrid solution in which Styla Product API fetches categories and products from an XML file but for product details, a Product Details Endpoint has been developed by the client, to enable adding products to the cart.
data =
action : ‘validateAddToCart’
code : model.get ‘productId’
source : ‘Artikeldetailseite’
So for the first of the two products above ths POST form data is: action=validateAddToCart&code=3925203&source=Artikeldetailseite
As a result, the product with this specific ID is added to the cart (quatity is always 1) at: https://www.obi.de/promotion/wohnideen/ and the cart update on the front-end is handled by the client's application
This is an example of a solution in which Styla Product API fetches all categories and products from one file. There is no "Add to Cart" functionality on the client's Styla content.
Source file:
http://transport.productsup.io/6699876b0348dc53e072/channel/39420/sidestep_shoes_shopping_styla.csv - this is where data for categories listing and search and images for backoffice.styla.com comes from
The above CSV file is the only product information source Styla gets from the client. No products are added to the cart at https://www.sidestep-shoes.de/de/blog and the URL on the overlay to link to product pages is sourced from the CSV file too.
Once you have any of the above running on your local, stage and production environment, please make sure everything is working fine:
Once Styla integrates with your product data source on stage or production, test the data coming from it in editor.styla.com and on your Styla front-end - by creating pages with products and checking them on your front-end.
If there are any problems that you cannot solve, please contact Styla support.