summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-11-23 01:55:38 -0500
committerJules Laplace <jules@okfoc.us>2015-11-23 01:55:38 -0500
commit0a05952ecb10d268e6c73a043c7b2b2bc5c12a36 (patch)
tree30d804d40513b2d008a9aab25e99a4212b577caf
parent7d9950316368d825510588ded16e5194b4840931 (diff)
display totals
-rw-r--r--StoneIsland/www/js/lib/cart/CartSummary.js20
-rw-r--r--StoneIsland/www/js/vendor/util.js6
2 files changed, 25 insertions, 1 deletions
diff --git a/StoneIsland/www/js/lib/cart/CartSummary.js b/StoneIsland/www/js/lib/cart/CartSummary.js
index 77c40b52..d4729182 100644
--- a/StoneIsland/www/js/lib/cart/CartSummary.js
+++ b/StoneIsland/www/js/lib/cart/CartSummary.js
@@ -15,6 +15,12 @@ var CartSummary = ScrollableView.extend({
this.$cart_body = this.$(".cart_body")
this.$cart_empty = this.$(".cart_empty")
this.scroller = new IScroll('#cart_summary', app.iscroll_options)
+
+ this.$rows = this.$(".rows")
+ this.$subtotal = this.$(".subtotal")
+ this.$shipping = this.$(".shipping")
+ this.$tax = this.$(".tax")
+ this.$total = this.$(".total")
},
show: function(){
@@ -45,9 +51,21 @@ var CartSummary = ScrollableView.extend({
console.log(data)
app.header.set_cart_count(data.Cart.Items.length)
- console.log("HEY")
+
this.parent.$itemcount.html(pluralize(data.Cart.Items.length, "ITEM", "S"))
+ this.$rows = this.$(".rows")
+
+ var subtotal = data.Cart.Totals.TotalToPay
+ var shipping_cost = data.Cart.DeliveryMethod.Selected.Amount.Total
+ var tax = 0
+ var total = data.Cart.Totals.TotalToPay
+
+ this.$subtotal.html( as_cash(subtotal) )
+ this.$shipping.html( as_cash(shipping_cost) )
+ this.$tax.html( as_cash(tax) )
+ this.$total.html( as_cash(total) )
+
this.$el.removeClass("empty").addClass("full")
this.deferScrollToTop()
},
diff --git a/StoneIsland/www/js/vendor/util.js b/StoneIsland/www/js/vendor/util.js
index 6523d50e..23f55d4c 100644
--- a/StoneIsland/www/js/vendor/util.js
+++ b/StoneIsland/www/js/vendor/util.js
@@ -28,6 +28,12 @@ function title_case (str) {
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
function pluralize (n,s,ss) { return n + " " + s + ( n == 1 ? "" : (ss || "s") ) }
+function as_cash(n){
+ var cents = ((n*100) % 100);
+ if (cents < 10) { cents = "0" + (cents|0) }
+ else { cents = cents|0 }
+ return "$" + (n|0) + "." + cents
+}
var E = Math.E
var PI = Math.PI