Skip to content

Instantly share code, notes, and snippets.

Created Aug 15, 2014
What would you like to do?
Shopify Ajax Cart Callback
// Create a global function that handles all cart-related JS
initCart = function (obj) {
// Do all cart things here
// If running as the ajax cart callback, an object is returned
if (obj.is_visible) {
// the cart is shown
} else {
// the cart was hidden
// From your general JS file, run initCart() on your /cart page
// In your theme.liquid file, initialize the ajax cart.
// Pass initCart as the callback function to onToggleCallback
// This will run the initCart function each time the cart is shown/hidden, passing an object back.
jQuery(function($) {
method: 'drawer',
onToggleCallback: initCart
Copy link

carolineschnapp commented Aug 15, 2014

You're fantastic, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment