Skip to content

Instantly share code, notes, and snippets.

@jparbros
Created January 5, 2015 18:53
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 jparbros/955fdb1da3dbe8736f00 to your computer and use it in GitHub Desktop.
Save jparbros/955fdb1da3dbe8736f00 to your computer and use it in GitHub Desktop.
window.confirmSetted = false;
function getAjaxCart() {
jQuery.ajax({
url: minicart_url,
dataType: 'json',
type : 'get',
success: function(data){
var div_element = jQuery("<div>");
jQuery(div_element).html(data.html);
if( jQuery("#cart-total").length > 0 ) {
var cart_total = text_cart_total.replace("%total%", data.summary_qty );
cart_total = cart_total.replace("%price%", data.subtotal );
jQuery("#cart-total").html( cart_total );
}
if( jQuery(div_element).find(".block-cart").length > 0){
jQuery('.block-cart').html( jQuery(div_element).find(".block-cart").first().html() );
}
if(jQuery('.block-cart .btn-remove').length > 0){
jQuery('.block-cart .btn-remove').attr('onclick','').unbind('click');
jQuery('.block-cart .btn-remove').off("click");
if(window.confirmSetted == true) {
jQuery(document).on('click', '.block-cart .btn-remove', function(e){
if(confirm( text_confirm_delete_item )){
deleteItemCart( jQuery(this).attr("href") );
}
// return false;
});
window.confirmSetted = true
}
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment