Versions Compared

Key

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

...

Description

Wizart Web Visualizer is a virtual fitting room executed as a standalone web application to be integrated into the client’s website. Its purpose is to allow the user to apply samples of finishing materials on photos of interiors that have previously been marked, as well as users’ personal interior photos. It displays information either from the PIM system (see below) or from the client’s database.

...

  • A web administration system that allows the client to quickly manage the data available in the PIM system and the data displayed in Wizart visualization products. Using this tool, the client can upload the necessary textures into the PIM system and use them in Wizart visualization products. For every client, a separate Admin Tool is used.

Wizart Web Visualizer is a virtual fitting room executed as a standalone web application to be integrated

Wizart Web Integration

Operational procedure

  1. Get access to the PIM Admin Tool (to be generated and issued by a Wizart administrator) and an API Token

  2. Import the necessary data into the PIM via the PIM Admin Tool (File upload requirements, PIM User Manual )

  3. Integrate the Wizart Web application into the client’s website

  4. Integration testing

  5. Release

Requirements to specialists


Basic knowledge of web layout and development:

  • HTML

  • JavaScript

  • CSS

System requirements

No specific requirements. The application may be integrated into any modern website.

Examples of possible integration areas

The Wizart Web Visualizer opening styles and elements can be completely customized per the client’s wishes.
Below are some examples of possible element layouts.

...

Product list page:

...

Product page:

...

Integrating the Wizart Web Visualizer application into a client’s website

You will need an API Token (to be generated and issued by a Wizart administrator) - api_token

  1. In the source file of the target page, add the required code in the <body> tag, as shown in the listing below.

Info

Since the Wizart Web Visualizer allows to open and visualize a specific product (SKU), please pay attention to how this is implemented separately.

Note

To avoid issues with the Wizart Web Visualizer appearing the CSS z-index property for wizart-fitting-room-object tag id has to be greater than z-index for the rest of popup windows on client web application.

Code Block
languagehtml
<body>

...

<button id="wizart-fitting-room-button" onClick="openFittingRoom()">
  Fitting room
</button>

<iframe 
  id="wizart-fitting-room-object"
  name="wizartFittingRoom" 
  role="dialog" 
  aria-label="Wizart Fitting Room." 
  type="text/html" 
  allowfullscreen
  >
</iframe>

<style>
  #wizart-fitting-room-object {
      z-index: 2147483647 !important;
      display: none;
      position: fixed !important;
      top: 0 !important;
      left: 0 !important;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.8);
      border: none;
  }
  
  #wizart-fitting-room-object.active {
    display: block;
  }
</style>

<script src="./wizart-integration.js"></script>

</body>

2. Using the listing below, create a js-file named wizart-integration.js: upload it to the existing source files of the client’s web application.

Code Block
languagejs
// TODO get api token from Wizart and set the value
const api_token = 'CLIENT_SPECIFIC_API_TOKEN';
// please do not change the server address
const server_address = 'https://pim-client.wizart.ai';

// bba (back button action) param is used to add back button to wizart component
const fittingRoomEndpoint = server_address
  + '/fitting-room'
  + '?api_token=' + api_token 
  + '&bba=true'
;

function wid() {
  let currentID = localStorage.getItem("w_uuid");
  if (!currentID) {
    function s4() {
      return Math.floor((1 + Math.random()) * 0x10000)
        .toString(16)
        .substring(1);
    }
    currentID = `${s4() + s4()}-${s4()}-${s4()}-${s4()}-${s4()}${s4()}${s4()}`;
    localStorage.setItem("w_uuid", currentID);
  }

  return currentID;
}

function openFittingRoom (searchQuery) {
  const componentEndpoint = searchQuery ? fittingRoomEndpoint + searchQuery : fittingRoomEndpoint;
  
  let fittingRoomObject = document.getElementById('wizart-fitting-room-object');
  const fittingRoomObjectContainer = fittingRoomObject.parentElement;

  fittingRoomObject.setAttribute('src', componentEndpoint);
  // object clonning is necessary as some browsers does not render "object" twice after changing data attribute
  const clonnedFittingRoomObject = fittingRoomObject.cloneNode(true);

  fittingRoomObjectContainer.appendChild(clonnedFittingRoomObject);
  fittingRoomObject.remove();

  clonnedFittingRoomObject.classList.add('active');
  
  // should be added to avoid duplicating scrollbars
  document.getElementsByTagName('html')[0].style.overflow = 'hidden';
  
  const queryParams = new URLSearchParams({
    v: 1,
    ds: "web",
    t: "event",
    tid: "UA-121898981-9",
    ec: "spi_entry_button",
    ea: "pressed",
    uid: wid(),
    dr: window?.location?.origin || "",
    z: Date.now(),
    cd1: !!searchQuery,
  }).toString();
  fetch(`https://www.google-analytics.com/collect?${queryParams}`);
}

// bba event - fired when back button is clicked at wizart component
window.addEventListener('message', function (event) {
  if (~event.origin.indexOf(server_address)) {
    // exactly 'close_overlay' as it's sent from wizart component
    if (event.data === 'close_overlay') {
      // return overflow of target page to initial state
      document.getElementsByTagName('html')[0].style.overflow = 'auto';

      document.getElementById('wizart-fitting-room-object').classList.remove('active');
    }
    
    if (event.data && event.data.eventName === 'wizart_shopping_cart') {
      // here you can process the data that comes from the shopping cart after clicking go_to_shop
    }
  }
});

document.addEventListener("DOMContentLoaded", () => {
  const buttons = document.querySelectorAll("#wizart-fitting-room-object");
  const queryParams = new URLSearchParams({
    v: 1,
    ds: "web",
    t: "event",
    tid: "UA-121898981-9",
    ec: "spi_entry_button",
    ea: "shown",
    uid: wid(),
    dr: window?.location?.origin || "",
    z: Date.now(),
    cd2: buttons.length > 1,
  }).toString();
  fetch(`https://www.google-analytics.com/collect?${queryParams}`);
});

3. Shopping cart.

An example of shopping cart integration is shown in the listing above. See line 42.

Event.data format:

Code Block
{
  eventName: 'wizart_shopping_cart',
  payload: [
    { 
      vendor_code: string,
      quantity: number, 
    },
  ],
}

4. Optional parameters:

Visualizer configuration: https://pim-admin.wizart.ai/configuration/web

  1. user_id – User identifier or Device identifier. Type string. Format: user_id=string.

  2. context - Type string. Format: context=string.

  3. custom_shopping_cart_link – Type string. This parameter takes precedence over the setting in the PIM configuration. Format: custom_shopping_cart_link=https://www.wizart.ai/

Integration example:

Code Block
const fittingRoomEndpoint = server_address
  + '/fitting-room'
  + '?api_token=' + api_token
  + '&bba=true'
  + '&user_id=string
  + '&context=string
  + '&custom_shopping_cart_link=https://www.wizart.ai/'
;

5. Save and move all the changes into the work environment of the client’s website.

6. Check and verify that the integration is operational.

The integration is now considered complete.

In case you have any additional questions or issues, please contact Wizart technical support: support@wizart.ai

Simple integration: Video tutorial

...

Here you can check different integration options.