Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Identifying the list of products in the shopping cart. To identify the list of products in the shopping cart you need to call the method postMessage.

    Code Block
    languagejs
    window.frames.wizartFittingRoom.onload = (() => {
      window.frames.wizartFittingRoom.postMessage({
        eventName: 'setShoppingCartStore',
        payload: [
          {
            vendor_code: 'vendor_code', // type string,
            quantity: 1, // type number,
          },
        ],
      }, '*');
    });
  2. To get the list of products from the shopping cart you need to call the method postMessage getShoppingCartStore. Web Visualizer will catch this request for getting the list of products from the shopping cart and trigger the event getShoppingCartStore on its side.
    Example:

    Code Block
    languagejs
    window.frames.wizartFittingRoom.onload = (() => {
        // Calling the event of getting the list of products from the shopping cart.
        window.frames.wizartFittingRoom.postMessage({
          eventName: 'getShoppingCartStore'
        }, '*');
    });
      
    // Subscription to the event of getting the list of products from the shopping cart.   
    window.addEventListener('message', (event) => {
      if (event.data && event.data.eventName === 'getShoppingCartStore') {
        // Event handling
      }
    }, false)
    
    Data format:
    event.data = {
      eventName: 'getShoppingCartStore',
      payload: { 
        vendor_code: 'vendor_code', // type string
        quantity: 1, // type boolean
      },
    }
  3. When a product is added to the shopping cart or its quantity is changed, the event addShoppigCartItem will be called.

    Code Block
    languagejs
    // Subscription to the event of adding product to the shopping cart
    window.addEventListener('message', (event) => {
      if (event.data && event.data.eventName === 'addShoppigCartItem') {
        // Event handling
      }
    }, false)
    
    Data format:
    event.data = {
      eventName: 'addShoppigCartItem',
      payload: { 
        vendor_code: 'vendor_code', // type string
      },
    }
  4. When the product is removed from the shopping cart, event removeShoppigCartItem with parameters vendor_code and removeALL will called. removeAll - value “true” is used in the case when the product was totally removed from the shopping cart.

    Code Block
    languagejs
    // Subscription to the event of removing product to the shopping cart
    window.addEventListener('message', (event) => {
      if (event.data && event.data.eventName === 'removeShoppigCartItem') {
        // Event handling
      }
    }, false)
    
    Data format:
    event.data = {
      eventName: 'addShoppigCartItemremoveShoppigCartItem',
      payload: { 
        vendor_code: 'vendor_code', // type string
        removeAll: true, // type boolean
      },
    }