Programmatically capture the Shopify cartUpdated 8 months ago
This suggestion isn't an official feature of our Chat widget, so our support for it is limited - we recommend that it be implemented by someone with a technical background.
You may want to link a specific cart with the current Chat user - to do so, we expose the captureShopifyCart method that allows you to provide the Shopify Cart of the Shopify user currently using the Chat.
The cart details will be displayed in the sidebar of the ticket on the helpdesk application.
1<script>2async function getCart(url = '/cart.json') {3 const response = await fetch(url, {4 method: 'GET',5 });6 return response.json();7}89var initGorgiasChatPromise = (window.GorgiasChat) ? window.GorgiasChat.init() : new Promise(function (resolve) { window.addEventListener('gorgias-widget-loaded', function () { resolve();})});1011initGorgiasChatPromise.then(function() {12 getCart().then(function(cart) {13 GorgiasChat.captureShopifyCart(cart);14 });15})16</script>