Third party apps, your theme, or any custom code can interact with EliteCart in the following ways.
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()
// 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.
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.