Home Forums WoodMart support forum Cart Widget Reply To: Cart Widget

#377888

Angelp357
Participant

Here it is since I can’t upload the file.

<script>
jQuery( document ).ready( function() {
var data = ‘action=woodmart_ajax_add_to_cart’;
jQuery.ajax({
url : woodmart_settings.ajaxurl,
data : data,
method : ‘POST’,
success : function(response) {
if (!response) {
return;
}
var fragments = response.fragments;
var cart_hash = response.cart_hash;

// Block fragments class
if (fragments) {
jQuery.each(fragments, function(key) {
jQuery(key).addClass(‘updating’);
});
}

// Replace fragments
if (fragments) {
jQuery.each(fragments, function(key, value) {
jQuery(key).replaceWith(value);
});
}
// Changes button classes
// Trigger event so themes can refresh other areas
// woodmartThemeModule.$body.trigger(‘added_to_cart’, [
// fragments,
// cart_hash,
// null
// ]);
},
error : function() {
console.log(‘ajax adding to cart error’);
},
complete: function() { }
});
} );
</script>