60s NAVY & RED GEOMETRIC PRINT MINI DRESS | UK 8 - 10
' + html + '';
switch (_config.feedbackPosition) {
case 'aboveForm':
addToCartForm.find('.product-add').before(feedback);
break;
case 'belowForm':
addToCartForm.find('.product-add').after(feedback);
break;
case 'nextButton':
default:
addToCartForm.find('input[type="submit"]').after(feedback);
break;
}
$('.ajaxified-cart-feedback').slideDown();
};
var _init = function() {
$(document).ready(function() {
$('form[action="/cart/add"]').submit(function(e) {
e.preventDefault();
var addToCartForm = $(this);
// Disable add to cart button.
var addToCartBtn = addToCartForm.find('input[type="submit"]');
addToCartBtn.attr('data-label', addToCartBtn.val());
addToCartBtn.val(_config.addingToCartBtnLabel).addClass('disabled').attr('disabled', 'disabled');
// Add to cart.
$.ajax({
url: _config.shopifyAjaxAddURL,
dataType: 'json',
type: 'post',
data: addToCartForm.serialize(),
success: function(itemData) {
// Re-enable add to cart button.
addToCartBtn.addClass('inverted').val(_config.addedToCartBtnLabel);
_showFeedback('success',' Added to Cart View Cart or Continue Shopping.',addToCartForm);
window.setTimeout(function(){
addToCartBtn.removeAttr('disabled').removeClass('disabled').removeClass('inverted').val(addToCartBtn.attr('data-label'));
}, _config.howLongTillBtnReturnsToNormal);
// Update cart count and show cart link.
$.getJSON(_config.shopifyAjaxCartURL, function(cart) {
if (_config.cartCountSelector && $(_config.cartCountSelector).size()) {
var value = $(_config.cartCountSelector).html();
$(_config.cartCountSelector).html(value.replace(/[0-9]+/,cart.item_count));
}
if (_config.cartTotalSelector && $(_config.cartTotalSelector).size()) {
if (typeof Currency !== 'undefined' && typeof Currency.money_format !== 'undefined') {
var newCurrency = '';
if ($('[name="currencies"]').size()) {
newCurrency = $('[name="currencies"]').val();
}
else if ($('#currencies span.selected').size()) {
newCurrency = $('#currencies span.selected').attr('data-currency');
}
if (newCurrency) {
$(_config.cartTotalSelector).html('' + Shopify.formatMoney(Currency.convert(cart.total_price, "GBP", newCurrency), Currency.money_format[newCurrency]) + '');
}
else {
$(_config.cartTotalSelector).html(Shopify.formatMoney(cart.total_price, "£{{amount}}"));
}
}
else {
$(_config.cartTotalSelector).html(Shopify.formatMoney(cart.total_price, "£{{amount}}"));
}
};
});
},
error: function(XMLHttpRequest) {
var response = eval('(' + XMLHttpRequest.responseText + ')');
response = response.description;
if (response.slice(0,4) === 'All ') {
_showFeedback('error', response.replace('All 1 ', 'All '), addToCartForm);
addToCartBtn.removeAttr('disabled').val(_config.soldOutBtnLabel).attr('disabled','disabled');
}
else {
_showFeedback('error', ' ' + response, addToCartForm);
addToCartBtn.removeAttr('disabled').removeClass('disabled').removeClass('inverted').val(addToCartBtn.attr('data-label'));
}
}
});
return false;
});
});
};
return {
init: function(params) {
// Configuration
params = params || {};
// Merging with defaults.
$.extend(_config, params);
// Action
$(function() {
_init();
});
},
getConfig: function() {
return _config;
}
}
})(jQuery);
Shopify.AjaxifyCart.init();