@deron
To run a JavaScript event on a Shopify cart update, you can use the Shopify AJAX API to detect when the cart has been updated and then trigger your JavaScript event accordingly.
Here's a basic example of how you can achieve this:
1 2 3 4 |
function onCartUpdate() { // Your JavaScript event code here console.log("Cart updated!"); } |
1 2 3 4 5 6 7 |
document.addEventListener('DOMContentLoaded', function() { // Set up event listener for when the cart is updated document.addEventListener('ajaxCart.afterCartLoad', function(event) { // Call your function when the cart is updated onCartUpdate(); }); }); |
Once you have added this code to your theme, your JavaScript event will run every time the cart is updated on your Shopify store. You can customize the 'onCartUpdate' function to perform any actions you want when the cart is updated, such as displaying a confirmation message or updating a counter.