company logo

Help center

Go to EliteCart
Powered by
All collectionsAdvanced settings and APIEliteCart API

EliteCart API

Methods to interact with EliteCart

Third party apps, your theme, or any custom code can interact with EliteCart in the following ways.

Methods you can call

You can call any of these methods:

// get the latest cart from Shopify and open the drawer 
window.EliteCart.openDrawerWithDataRefresh()

// open the cart drawer, but don't refresh data
window.EliteCart.openDrawerWithoutDataRefresh()

// close the cart drawer
window.EliteCart.closeDrawer()

// close the two-step cart and open the regular cart
window.EliteCart.switchFromTwoStepToRegularCart()

// refresh the cart (useful e.g. if you use other apps that inject into EliteCart)
window.EliteCart.refreshCart()

// reinitialize the reward bar, e.g. after setting overwrites like "hideReward2"
window.dispatchEvent(new CustomEvent("eliteCart:reinitializeRewardBar"));

// reinitialize all eliteCart settings including locales from the window
window.dispatchEvent(new CustomEvent("eliteCart:reinitializeSettings"));

Events you can listen to

// Do something when a EliteCart added a product to cart
document.addEventListener("eliteAddProductToCart", function(event) {
    console.log("Product added to cart!");
});

See how we use this event for a custom datalayer implementation:

Google Analytics Events missing Add To Cart event

Modifying custom Datalayer implementations

// Do something when a EliteCart was updated
document.addEventListener("eliteCartUpdated", function(event) {
    console.log("Cart was updated");
});

E.g. useful when you inject something into our cart that you’d like to update, or when you want to add information on the product page you are on if the cart updates.

Settings overwrite

// Prohibit EliteCart from adding products to cart. 
window.eliteCartSkipAddToCart = true

// Prohibit EliteCart from adding products to cart 
// and also prohibit it from running preventDefault on an add-to-cart button click
window.eliteCartSkipAddToCartAndDoNotPreventDefault = true

Typically used if a competing app / custom code wants to handle the add to cart on certain pages. use the first if another app handles the cart via JavaScript. Use the second if the form should normally submit, typically done by the theme itself. EliteCart can still automatically open if you set the setting to watch for external cart changes and open based on it in the advanced settings in EliteCart.

Open Cart via URL parameters

You can also open EliteCart via a URL parameter:

https://yourstore.myshopify.com/?elitecart-open=true

This is useful e.g. if you use Shopify links to auto-add a product to cart and would like to open EliteCart afterwards. Commonly done in email campaigns.

info icon
Missing API functionality? Reach out via our chat.

Did this answer your question?
😞
😐
😁