(function($) { var ShoppingCart = window.ShoppingCart = function() { var errorMessage = ""; var cartAmount = ""; var cartItems = ""; return { addItem : function(itemNumber, quantity) { if ($("#uc-content").is(":visible")) { $("#uc-content").stop().remove(); } var params = "itemNumber=" + itemNumber + "&quantity=" + quantity; $.ajax({ type: "POST", url: "//www.swstrings.com/shopping/cart/add", data: params, async: false, dataType: "json", success: function (data) { errorMessage = data.errorMessage; }, error: function(XMLHttpRequest, textStatus, errorThrown) { errorMessage = "An Error Occurred while adding the item to your cart."; } }); ShoppingCart.summary.update(); }, removeItem : function(itemNumber) { $.ajax({ type: "POST", url: "//www.swstrings.com/shopping/cart/remove", data: {itemNumber:itemNumber}, async: false, dataType: "json", success: function (data) { errorMessage = data.errorMessage; }, error: function(XMLHttpRequest, textStatus, errorThrown) { errorMessage = "An Error Occurred while removing the item from your cart."; } }); $("#mc-cart-amount").html(ShoppingCart.summary.getCartAmount()); ShoppingCart.summary.update(); }, error : function() { return errorMessage }, showCart : function() { // If already visible, leave var path = $(location).attr("href"); if ($("#uc-content").is(":visible") || path.match(/cart$/)) { return; } ($("#wrapper").append("
")); $("#uc-content").append("
");
$("#uc-content").append("