diff options
Diffstat (limited to 'StoneIsland')
| -rw-r--r-- | StoneIsland/www/index.html | 14 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/cart/CartSummary.js | 45 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/cart/CartView.js | 2 |
3 files changed, 42 insertions, 19 deletions
diff --git a/StoneIsland/www/index.html b/StoneIsland/www/index.html index 8cff6b83..aeb1eb61 100644 --- a/StoneIsland/www/index.html +++ b/StoneIsland/www/index.html @@ -535,7 +535,7 @@ <!-- CART ================================================ --> <div id="cart"> - <h1>YOUR CART / <span class="itemcount">2 ITEMS</h1> + <h1>YOUR CART / <span class="itemcount"></h1> <div class="steps"> <span class="summary_step">SUMMARY</span> @@ -550,10 +550,10 @@ <div class="cart_body"> <div class="rows"> <script type="text/html" class="template"> - <div class="cart_item_image"> + <div class="cart_item_image"> <img src="{{image}}"> - </div> - <div class="cart_item_info"> + </div> + <div class="cart_item_info"> <span class="sku">{{sku}}</span> <span class="title">{{title}}</span> <span class="type">{{type}}</span> @@ -562,11 +562,11 @@ <div class="meta-color"><b>COLOR:</b> {{color}}</div> <div class="meta-quantity"><b>QUANTITY:</b> {{quantity}}</div> </div> - </div> - <div class="cart_item_price"> + </div> + <div class="cart_item_price"> <span class="remove">x Remove from cart</span> <span class="price">{{price}}</span> - </div> + </div> </script> </div> <div class="cart-summary"> diff --git a/StoneIsland/www/js/lib/cart/CartSummary.js b/StoneIsland/www/js/lib/cart/CartSummary.js index e70f152a..209e3102 100644 --- a/StoneIsland/www/js/lib/cart/CartSummary.js +++ b/StoneIsland/www/js/lib/cart/CartSummary.js @@ -48,8 +48,12 @@ var CartSummary = ScrollableView.extend({ this.data = data console.log("CART", data) + + if (! data.Cart.Items || data.Cart.Items.length == 0) { + return this.empty() + } - this.update_counts() + this.updateCounts() this.$rows.empty() @@ -104,29 +108,34 @@ var CartSummary = ScrollableView.extend({ .replace(/{{color}}/, color_name) .replace(/{{quantity}}/, 1) .replace(/{{price}}/, as_cash(details.Item.Price.DiscountedPrice)) + $el.data("price", details.Item.Price.DiscountedPrice) $el.html(t) this.deferScrollToTop() }.bind(this)) }.bind(this)) - var subtotal = data.Cart.Totals.TotalWithoutPromotions - 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.updateTotals() this.el.className = "full" this.deferScrollToTop() }, - update_counts: function(){ + updateCounts: function(){ app.header.set_cart_count(this.data.Cart.Items.length) this.parent.$itemcount.html(pluralize(this.data.Cart.Items.length, "ITEM", "S")) }, + + updateTotals: function(){ + var subtotal = this.data.Cart.Totals.TotalWithoutPromotions + var shipping_cost = this.data.Cart.DeliveryMethod.Selected.Amount.Total + var tax = 0 + var total = this.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) ) + }, empty: function(){ app.footer.hide() @@ -146,7 +155,21 @@ var CartSummary = ScrollableView.extend({ remove_item: function(e){ var $el = $( e.currentTarget ).closest(".cart_item_row") var data = $el.data() + data.Cart.Totals.TotalWithoutPromotions -= data.price + data.Cart.Totals.TotalToPay -= data.price + + this.data.Cart.Items = this.data.Cart.Items.filter(function(item){ + return ( item['Code10'] !== data.code || item['Size'] !== data.size) + }) + + this.updateTotals() + this.updateCounts() $el.remove() + + if (this.data.Cart.Items.length == 0) { + this.empty() + } + sdk.cart.delete_item({ data: { Code10: data.code, diff --git a/StoneIsland/www/js/lib/cart/CartView.js b/StoneIsland/www/js/lib/cart/CartView.js index 7d0476e9..8bea43dc 100644 --- a/StoneIsland/www/js/lib/cart/CartView.js +++ b/StoneIsland/www/js/lib/cart/CartView.js @@ -22,7 +22,7 @@ var CartView = View.extend({ sdk.cart.get_status({ success: function(data){ this.summary.data = data - this.summary.update_counts() + this.summary.updateCounts() }.bind(this), error: function(data){ console.log(data) |
