diff --git a/ko-cart/index.html b/ko-cart/index.html index 3e6a8dc..a67ca75 100644 --- a/ko-cart/index.html +++ b/ko-cart/index.html @@ -131,7 +131,27 @@ Total Items: Price: - + diff --git a/ko-cart/js/viewmodel.js b/ko-cart/js/viewmodel.js index dcd391f..02a3cc4 100644 --- a/ko-cart/js/viewmodel.js +++ b/ko-cart/js/viewmodel.js @@ -83,6 +83,13 @@ var vm = (function () { return total; }) + var removeFromCart = function (data) { + var units = data.units(); + var stock = data.product.stock(); + data.product.stock(units + stock); + cart.remove(data); + } + return { // first chapter searchTerm: searchTerm, @@ -93,7 +100,8 @@ var vm = (function () { cart: cart, showCartDetails: showCartDetails, totalItems: totalItems, - grandTotal: grandTotal + grandTotal: grandTotal, + removeFromCart: removeFromCart }; })(); ko.applyBindings(vm);