Javascript API of plugins

Note: To understand this chapter you should be familiar with's core Javascript API.

To make the use of Javascript Core API more simple, some default plugins expose their own API which contains wrapper methods e.g. for working with shopping cart.

Example: Add product to shopping cart

For example, the WAI/Customers/Cart plugin contains its own main.js file.

Download the WAI/Customer/Cart's main.js file

In this file, an addProduct method is declared:

PluginWAICustomerCart.prototype.addProduct = function (idProduct, qty, success) {
  let _this = this;

      'idProduct': idProduct,
      'qty': qty,
      'cartAction': 'addToCart',
    function (data) {
      if (typeof success == 'function') {

This method requires three arguments, as expected:

The callback for success then calls the updateHeaderOverview method which is declared elsewhere - in your theme. With this, you - as the theme designer - only need to implement the updateHeaderOverview method in your theme's Javascript which does necessary visualisation.

Browse through default plugins to learn what APIs they expose for you.

Your theme's javascript

Finally, you need to create the javascript code in your theme. Or you can reuse one from the Basic theme.

Read the chapter Javascript for your theme to learn how to create the javascript for your theme.

E-commerce development framework