...
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 language js window.frames.wizartFittingRoom.onload = (() => { window.frames.wizartFittingRoom.postMessage({ eventName: 'setShoppingCartStore', payload: [ { vendor_code: 'vendor_code', // type string, quantity: 1, // type number, }, ], }, '*'); });
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 eventgetShoppingCartStore
on its side.
Example:Code Block language js 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 }, }
When a product is added to the shopping cart or its quantity is changed, the event
addShoppigCartItem
will be called.Code Block language js // 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 }, }
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 language js // 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 }, }