Skip to content

Instantly share code, notes, and snippets.

@adamjudd
Created April 26, 2012 05:10
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 adamjudd/a750a52ac8274226e056 to your computer and use it in GitHub Desktop.
Save adamjudd/a750a52ac8274226e056 to your computer and use it in GitHub Desktop.
fcc.events.cart.postprocess = new FC.client.event();
fcc.events.cart.postprocess.add(function(){
fcc.cart_update();
return "pause";
});
fcc.events.cart.postprocess.add(function(){
buildFullCart(FC.json.products);
});
FC.client.prototype.cart_update = function() {
var self = this;
jQuery.getJSON('https://' + this.storedomain + '/cart.php?cart=get&output=json' + this.session_get() + '&callback=?', function(data) {
FC.json = data;
if ( ! self.session_initialized == true) {
self.session_initialized = true;
FC.session_id = data.session_id;
self.session_set();
self.session_get();
}
// "Minicart" Helpers
(FC.json.product_count > 0) ? jQuery("#fc_minicart, .fc_minicart").show() : jQuery("#fc_minicart, .fc_minicart").css("display","none");
// update values
jQuery("#fc_quantity, .fc_quantity").html("" + FC.json.product_count);
jQuery("#fc_total_price, .fc_total_price").html("" + self._currency_format(FC.json.total_price));
// Execute the ready event on intial pageload, if it's defined
if (self.events.cart.ready.counter == 0) {
self.events.cart.ready.execute();
} else {
self.events.cart.postprocess.resume();
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment