Skip to content

Instantly share code, notes, and snippets.

@resistorsoftware
Created July 27, 2010 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save resistorsoftware/492723 to your computer and use it in GitHub Desktop.
Save resistorsoftware/492723 to your computer and use it in GitHub Desktop.
// ---------------------------------------------------------
// POST to cart/update.js returns the cart in JSON.
// To clear a particular attribute, set its value to an empty string.
// Receives attributes as a hash or array. Look at comments below.
// ---------------------------------------------------------
Shopify.updateCartAttributes = function(data, callback) {
var params = {
type: 'POST',
url: '/cart/update.js',
data: data,
dataType: 'json',
success: function(cart) {
if ((typeof callback) === 'function') {
callback(cart);
}
else {
Shopify.onCartUpdate(cart);
}
},
error: function(XMLHttpRequest, textStatus) {
Shopify.onError(XMLHttpRequest, textStatus);
}
};
jQuery.ajax(params);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment