Skip to content
On this page

Cart Update Event

Cart Update event is triggered when the cart a product is added, updated or deleted from the shopping cart. Event component is also triggered when mounted which means it runs when page is visited or refreshed.

This event is mostly used for updating the cart count in the header.

Initialize the SDK

First thing you should do is initialize the SDK by adding the following line to your website:


<script type='text/javascript' dev-mount-point
        src='./components/sdk/main.js?store-id={STORE_ID}&locale={LOCALE}'></script>

Store Id and Locale

You should replace {STORE_ID} with your store Id and {LOCALE} with your locale.

Cart Update Event Component

Once the SDK is initialized, you can trigger the Cart Update event by adding the following line to your website:

QSPay.EventBasketUpdate({
  callback: (data) => {
    // data.total = Number. it is the total amount of the cart
    // data.products = Number. it is the number of products in the cart
    
    var headerCartProductCountElement = document.getElementById('header-cart-count');
    var headerCartTotalElement = document.getElementById('header-cart-total');
    
    headerCartTotalElement.innerHTML = data.total.toFixed(2) + ''
    headerCartCount.innerHTML = data.products;
  }
}).render('body')