Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Add the definition of the custom styles

...

Code Block
languagexml
titleAdd-Product Widget
<iframe style="width: 200px; height: 100px;" src="https://secure.affilibank.de/widget/cart/add?productId={Produkt-Id}&countryId={Country-Id}&customStyles={Custom-Styles}" width="400" height="250" frameborder="0"></iframe>

...

PlaceholderPossible valuesDescription
{Produkt-Id}
Alle unsigned integer

Product id is shown in product list of your vendor account.

{Country-Id}
"de", "en", ....

The language to translate the add-product widget into.

{Custom-Styles}
stringUrl-encoded JSON-string that describes the styles, see definition below.

Cart Widget

Use the following code to integrate. Use the styling attributes bottom: 0px; right: 0px; to determine the position of the widget.

Code Block
languagexml
titleCart Widget
<iframe id="cartWidget" style="position: fixed; z-index: 9999; bottom: 0px; right: 0px;" src="https://secure.affilibank.de/widget/cart?countryId={Country-Id}&vendor={Vendor}&formConfig={Form-Configuration}&customStyles={Custom-Styles}" frameborder="0"></iframe>

...

PlaceholderPossible valuesDescription
{Vendor}
string

The name / id of the vendor on the platform

{Country-Id}
"de", "en", ....

The country id in this case determines the country for the delivery address. The value added tax is also initially calculated using this parameter. Can be changed again in the order form

{Form-Configuration}
12345

If you want to assign a configuration of an existing product to the order form in the checkout, enter the product ID of the corresponding product for the formConfig parameter.

{Custom-Styles}
stringUrl-encoded JSON-string that describes the styles, see definition below.


To prevent the Cart widget from covering the target page with a transparent element in the folded-in state, a Javascript must be installed in the target page.

Code Block
languagexml
titleEinbinden des Javascripts zur Steuerung des Cart Widget
<script src="https://secure.affilibank.de/_files/js/cart_widget.js"></script>

Custom Styles

In order to ensure that vendors have the opportunity to define custom styles for specific elements, it is possible to specify custom styles in the URL of the iframe. At the moment the following element can be styled:

Element nameElement key
Product name
productName
Product price
productPrice
"Add to Cart" Button
addToCartButton
"Buy now" Button
buyNowButton


The mapping of the element keys to the elements is illustrated in the following diagrams:

Image AddedImage Added


The custom styles should be specified in the JSON-format, for example as follows:

Code Block
languagejs
titleExample of the custom styles configuration
{
  "buyNowButton": {
    "backgroundColor": "red"
  },
  "addToCartButton": {
    "color": "green",
    "backgroundColor": "yellow"
  },
  "productName": {
    "color": "blue"
  },
  "productPrice": {
    "color": "magenta"
  }
}


Some of the possible properties are:

Property nameDescription
color
Font color of the element
backgroundColor
Background color of the element (for example, button)

In this fashion you can specify any CSS property of the element. Notice that CSS properties that contain a hyphen ('-') should be specified in camel case (i.e. for the CSS property font-size one should write fontSize).

In order to pass these properties to the iframe, they have to be serialized (URL-encoded). For example, one can use the following tool: http://www.url-encode-decode.com/. On the left side one specifies the custom styles as in the code block above, then clicks "Encode URL", and then one gets a serialized string on the right hand side. Then one has to copy the string and pass it as the customStyles parameter to the iframe (see break-down of the iframe URL above for reference).

The resulting URL could the look somewhat like this:

Code Block
languagexml
titleExample URL of the iframe
https://secure.affilibank.de/widget/cart/add?productId=102&countryId=de&locale=de_DE&customStyles=%7B%0D%0A%20%20"buyNowButton":%20%7B%0D%0A%20%20%20%20"backgroundColor":%20"red"
%0D%0A%20%20%7D,%0D%0A%20%20"addToCartButton":%20%7B%0D%0A%20%20%20%20"color":%20"green",%0D%0A%20%20%20%20"backgroundColor":%20"yellow"%0D%0A%20%20%7D,%0D%0A%20%20
"productName":%20%7B%0D%0A%20%20%20%20"color":%20"blue"%0D%0A%20%20%7D,%0D%0A%20%20"productPrice":%20%7B%0D%0A%20%20%20%20"color":%20"magenta"%0D%0A%20%20%7D%0D%0A%7D