diff --git a/ko-cart/index.html b/ko-cart/index.html
index 67b2aab..3e6a8dc 100644
--- a/ko-cart/index.html
+++ b/ko-cart/index.html
@@ -127,7 +127,10 @@
-
+
diff --git a/ko-cart/js/viewmodel.js b/ko-cart/js/viewmodel.js
index 8e88005..c91dfc9 100644
--- a/ko-cart/js/viewmodel.js
+++ b/ko-cart/js/viewmodel.js
@@ -65,6 +65,23 @@ var vm = (function () {
}
cart(tmpCart);
};
+
+ var totalItems = ko.computed(function() {
+ var tmpCart = cart();
+ var total = 0;
+ tmpCart.forEach(function(item) {
+ total += parseInt(item.units(), 10);
+ });
+ return total;
+ })
+ var grandTotal = ko.computed(function() {
+ var tmpCart = cart();
+ var total = 0;
+ tmpCart.forEach(function(item) {
+ total += (item.units() * item.product.price());
+ });
+ return total;
+ })
return {
// first chapter