Installing Quizzes with Custom Carts
Okendo Quizzes integrates with basic Shopify themes by refreshing the cart counter and updating the cart drawer if available.
If your store uses a theme that is not fully supported, or uses additional cart plugins or custom cart integrations, you may need to perform some additional steps to make sure that the Quiz (particularly the results page, where there are cart interactions) is fully functional for your online store.
Variant added event
Add an event listener in your theme code to react to whenever an item has been added to the cart from the Quiz results page:
document.addEventListener('oke_connect_cart_itemVariantAdded', async event => {
console.log(event.detail);
});
“Add To Cart” doesn’t update the shopping cart icon
Use the oke_connect_cart_itemVariantAdded
event to trigger your custom cart to update. The following is an example only. Your custom cart API may be different:
document.addEventListener('oke_connect_cart_itemVariantAdded', async event => {
// Example only. Check your custom cart API.
const { detail } = event;
const customEvent = new CustomEvent('theme:cart:update', { detail: { id, quantity } });
document.dispatchEvent(customEvent);
});
“Add To Cart” doesn’t open the cart drawer
Use the oke_connect_cart_itemVariantAdded
event to trigger the cart drawer for your custom cart. Some custom carts may open the cart drawer for you at the same time as the cart items are updated:
document.addEventListener('oke_connect_cart_itemVariantAdded', async event => {
// Example only. Check your custom cart API.
window.cart.openCartDrawer();
});
Last updated