8SELECT - Integration Documentation
8SELECTService Status
  • 8.HX PLATFORM
  • Shop Integration
    • 8.SDK Web (JavaScript SDK)
    • Widgets
      • βž•Add more elements, like custom headline
      • πŸ‘»Hide recommendation area in case there is no content
      • πŸ”ŽAdding widgets after 8.SDK was loaded
      • πŸ—ΊοΈInternationalization
    • Shopping Cart
    • Checkout Tracking
    • Product Export
    • A/B Testing
    • Single Page Application
    • Tag Manager
    • Data Privacy / Cookies / GDPR
  • Widgets
    • 8.SIMILAR
    • 8.SET
    • 8.SET Custom
    • Touchpoints
      • Product Page
      • Cart Layer
      • Cart
      • Content Page
  • Product Export
    • Data Transfer
    • File Format
    • Base Data
      • Details and examples
    • Fashion Content Pool
      • Details and examples
    • Image Bot
  • Sandbox
    • Demo-Integration
    • Demo-Mode
  • API
    • Changelog
      • 2.0.0
      • 1.0.1
    • General
      • Introduction
      • Authentication
      • Pagination
      • Exceptions
      • GraphQL Schema
    • Examples
      • 8.SIMILAR
      • 8.SET
      • 8.SET Custom
      • Product Page - All Content
  • API Tracking
    • Changelog
    • General
      • Introduction
      • Authentication
      • Context
      • User Identification
      • Event Validation
    • Events
      • view
        • How to evaluate if view event can be sent
        • User views 8.SET content
      • interact
        • User clicks on a product within 8.SET content
        • User adds a product to their card from within 8.SET content
        • Example what is not a product interaction
      • order
Powered by GitBook
On this page

Was this helpful?

  1. Shop Integration

Shopping Cart

Allow to add products to your cart from within 8SELECT widgets

PreviousInternationalizationNextCheckout Tracking

Last updated 1 year ago

Was this helpful?

Many widgets allow a product to be added directly to the shopping cart.

Widgets that allow to add products to the cart will call the function _eightselect_shop_plugin.addToCart(). This function can then directly contain the code to add something to the shopping cart or call another function that is already implemented in the shop frontend.

To identify a product variant that should be added to the cart we currently only have the sku available. For sku, the same value as in the is used.

// 8.SDK Web configuration for shop's cart API
<script type="text/javascript">
  window._eightselect_shop_plugin = window._eightselect_shop_plugin || {};
  window._eightselect_shop_plugin.addToCart = function (sku, quantity, Promise) {
    // the function has to return a promise
    // you can use the injected Promise or use your own polyfill
    
    // add your cart logic here
    // this is just an example - shopApi is something you actually have to implement
    return new Promise(function(resolve, reject) {
      var response = shopApi.add2cart(sku);
      if (response === "OK") {        
        return resolve("done");
      }

      return reject(new Error("add2cart failed"));
    }
  }
</script>

// 8.SDK Web
<script type="text/javascript">
    ...
</script>

The script is needed on all pages where widgets are used.

A Promise object is injected into the function. A polyfill is provided for older browsers. This means that this does not have to be covered by the shop.

product export