Skip to content

Instantly share code, notes, and snippets.

Created August 15, 2014 19:58
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cshold/93b6bf8b90a6adbb68c0 to your computer and use it in GitHub Desktop.
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

You're fantastic, thanks!

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