";
// Add the new book
$('#tblItems > tbody:last').append(row);
totalItem = totalItem + 1;
// Update the total
$('#ctl00_floating_lblTotal').text('TOTAL: ' + result[item].FormatedTotalCart);
//Remove bindings for the click to prevent the event fired more than one time
$('.btnRemoveFromCart').unbind('click');
//Bind the delete button with the function
$('.btnRemoveFromCart').click(function () {
$.checkOutManager('removeItem', $(this).attr('itemid'));
return false;
});
//Remove bindings for the click to prevent the event fired more than one time
$('.btnMoveToWishList').unbind('click');
//Move to wish List
$('.btnMoveToWishList').click(function () {
$.checkOutManager('moveItemToWishList', $(this).attr('itemid'));
return false;
});
}
// Update the total
$('#ctl00_floating_lblCount').text(totalItem);
$('#ctl00_lblCount').text(totalItem);
var currency = $('#ddlCurrency').val();
if (currency != "USD" && $.isFunction(window.ConvertShoppingCartPrices))
ConvertShoppingCartPrices(currency, $('#ddlSymbol').val());
}
function updateShoppingCartMSG(result, id, applyDiscount) {
var message = "";
if (result.Id == -2) {
message = "The book already exists in the shopping bag";
$.prompt(message);
} else {
if (result.Id == -10) {
message = "We're sorry, this item has been sold";
$.prompt(message);
} else {
if (result.Id == -3) {
message = "We're sorry, this item currently on reserve, inquire for more information";
$.prompt(message);
} else {
if (result.Id == -777) {
message = "There was an error moving the book from the Wish List";
$.prompt(message);
} else {
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
window.location.href = window.location.protocol + "//" + window.location.host + "/Checkout/Items.aspx";
}
TrackAddShoppingCartItem(result);
//Elimino el mensaje de Empty Items
$('.EmptyItems').remove();
$('.jspContainer').show();
$('.checkOut').show();
var text = $('#ctl00_floating_lblCount').text();
//+ " / " + result.Id;
var totalItem = parseInt(text ? text : 0);
var row = "";
var currency = $('#ddlCurrency').val();
CurrencyConverterWS.CurrencyConversionFromBook(result.Id, currency, $('#ddlSymbol').val(), applyDiscount,
function (price) {
row = "
";
$("#tblItems tbody:last").append(row);
// Update the total
$('#ctl00_floating_lblCount').text(totalItem + 1);
$('#ctl00_lblCount').text(totalItem + 1);
//Remove bindings for the click to prevent the event fired more than one time
$('.btnRemoveFromCart').unbind('click');
//Bind the delete button with the function
$('.btnRemoveFromCart').click(function() {
$.checkOutManager('removeItem', $(this).attr('itemid'));
return false;
});
//Remove bindings for the click to prevent the event fired more than one time
$('.btnMoveToWishList').unbind('click');
//Move to wish List
$('.btnMoveToWishList').click(function() {
$.checkOutManager('moveItemToWishList', $(this).attr('itemid'));
return false;
});
showWindow(true, function() {});
var bookIds = $("#tblItems tr td:first-child").map(function() {
return $(this).attr("class");
}).get();
wireUpEvents(bookIds);
CurrencyConverterWS.CurrencyConversionForBooksSum(bookIds, currency, $('#ddlSymbol').val(), function (totalPrice) {
// Update the total
$('#ctl00_floating_lblTotal').text('TOTAL: ' + totalPrice);
}, function () { });
});
}
}
}
}
}
function updateShoppingCartAfterRemove(result) {
if (result.Id == -2) {
$.prompt("The book you are trying to delete don´t exists.");
return;
}
if (result.Id == -3) {
$.prompt("You need to login.");
return;
}
TrackRemoveShoppingCartItem(result);
var text = $('#ctl00_floating_lblCount').text();
//+ " / " + result.Id;
var totalItem = parseInt(text ? text : 0);
// Update the total
$('#ctl00_floating_lblCount').text(totalItem - 1);
$('#ctl00_lblCount').text(totalItem - 1);
//Delete the item
$('.' + result.Id).remove();
var bookIds = [];
$('#tblItems').find('.pric').each(function () {
var book = $(this).parent().attr('class');
if ($.inArray(book, bookIds) == -1) {
bookIds.push(book);
}
});
CurrencyConverterWS.CurrencyConversionForBooksSum(bookIds, $('#ddlCurrency').val(), $('#ddlSymbol').val(), function (totalPrice) {
// Update the total
$('#ctl00_floating_lblTotal').text('TOTAL: ' + totalPrice);
}, function () { });
if ((totalItem - 1) == 0) {
//coloco el mensaje de EmptyItems
$('.jspContainer').fadeOut();
$('.checkOut').fadeOut();
$('#itemsContainer').append('
You have 0 items in your shopping bag, please add an item to continue.
');
}
}
function showShoppingCart(items) {
var text = $('#msgShooping').text();
$.each(items, function () {
text = text + " / " + this.Id;
});
$('#msgShooping').text(text);
showWindow(true);
}
function showWindow(show, fadeInCallback) {
var top = $(window).scrollTop() + $(window).height() / 2 - $('#popCart').height() / 2;
$('.popCart').css("top", top);
if (!$('.popCart').is(':visible') && show) {
$("#divGrayOutBag").fadeIn();
$(".bag-box").fadeIn(500, fadeInCallback);
$(".view-chart").toggleClass("active");
visible = true;
}
else if (!show) {
$(".bag-box").fadeOut();
$("#divGrayOutBag").fadeOut();
$(".view-chart").toggleClass("active");
visible = false;
}
}
function toggleWindow() {
//$('#checkoutFloating').toggle("fast");
$(".bag-box").toggle();
$(".view-chart").toggleClass("active");
visible = !visible;
}