summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-11-21 15:57:50 -0500
committerJules Laplace <jules@okfoc.us>2015-11-21 15:57:50 -0500
commitc223032bbd67fe5b6ad1334ce81a3f51a7631bfc (patch)
tree9f832d23e348a3b92030ec7da6053d7eece24254
parent29380aa560c05186aa67b7b36d4a40c65e570d35 (diff)
cart empty warning
-rw-r--r--StoneIsland/www/css/cart.css17
-rw-r--r--StoneIsland/www/index.html71
-rw-r--r--StoneIsland/www/js/lib/cart/CartConfirm.js3
-rw-r--r--StoneIsland/www/js/lib/cart/CartPayment.js3
-rw-r--r--StoneIsland/www/js/lib/cart/CartShipping.js3
-rw-r--r--StoneIsland/www/js/lib/cart/CartSummary.js28
-rw-r--r--StoneIsland/www/js/lib/cart/CartThanks.js3
-rw-r--r--StoneIsland/www/js/lib/cart/CartView.js18
-rw-r--r--StoneIsland/www/js/sdk/auth.js6
-rw-r--r--StoneIsland/www/js/sdk/cart.js13
-rw-r--r--test/test/04-cart.js6
11 files changed, 114 insertions, 57 deletions
diff --git a/StoneIsland/www/css/cart.css b/StoneIsland/www/css/cart.css
index e8a1e8fb..2a409177 100644
--- a/StoneIsland/www/css/cart.css
+++ b/StoneIsland/www/css/cart.css
@@ -23,8 +23,21 @@
color: #bbb;
width: 33%;
}
-#cart .steps span.active {
- color: #888;
+#cart.summary .summary_step,
+#cart.payment .payment_step,
+#cart.shipping .shipping_step {
+ color: #000;
+}
+
+.full .cart_body { display: block; }
+.empty .cart_empty { display: block; }
+.cart_body {
+ display: none;
+}
+.cart_empty {
+ display: none;
+ text-align: center;
+ margin: 50px 0;
}
#cart.summary #cart_summary { display: block }
diff --git a/StoneIsland/www/index.html b/StoneIsland/www/index.html
index edc8b35f..f82d71c2 100644
--- a/StoneIsland/www/index.html
+++ b/StoneIsland/www/index.html
@@ -507,44 +507,49 @@
<h1>YOUR CART / <span class="itemcount">2 ITEMS</h1>
<div class="steps">
- <span class="summary">SUMMARY</span>
- <span class="shipping">SHIPPING</span>
- <span class="payment">BILLING</span>
+ <span class="summary_step">SUMMARY</span>
+ <span class="shipping_step">SHIPPING</span>
+ <span class="payment_step">BILLING</span>
</div>
<div id="cart_summary">
<div class="scroll">
- <div class="rows">
- <script type="text/html" class="template">
- <div>
- <img src="{{image}}">
- <b>{{sku}}</b><br>
- <span class="title">{{title}}</span>
- <span class="type">{{type}}</span>
- <span class="meta">
- <b>SIZE:</b> {{size}}<br>
- <b>COLOR:</b> {{color}}<br>
- <b>QUANTITY:</b> {{quantity}}<br>
- </span>
- <span class="price">{{price}}</span>
- </div>
- </script>
- </div>
- <div>
- <span class="label">SUB TOTAL</span>
- <span class="subtotal"></span>
- </div>
- <div>
- <span class="label">ESTIMATED SHIPPING<br>& HANDLING</span>
- <span class="shipping"></span>
- </div>
- <div>
- <span class="label">TAX</span>
- <span class="tax"></span>
+ <div class="cart_body">
+ <div class="rows">
+ <script type="text/html" class="template">
+ <div>
+ <img src="{{image}}">
+ <b>{{sku}}</b><br>
+ <span class="title">{{title}}</span>
+ <span class="type">{{type}}</span>
+ <span class="meta">
+ <b>SIZE:</b> {{size}}<br>
+ <b>COLOR:</b> {{color}}<br>
+ <b>QUANTITY:</b> {{quantity}}<br>
+ </span>
+ <span class="price">{{price}}</span>
+ </div>
+ </script>
+ </div>
+ <div>
+ <span class="label">SUB TOTAL</span>
+ <span class="subtotal"></span>
+ </div>
+ <div>
+ <span class="label">ESTIMATED SHIPPING<br>& HANDLING</span>
+ <span class="shipping"></span>
+ </div>
+ <div>
+ <span class="label">TAX</span>
+ <span class="tax"></span>
+ </div>
+ <div>
+ <span class="label">TOTAL</span>
+ <span class="total"></span>
+ </div>
</div>
- <div>
- <span class="label">TOTAL</span>
- <span class="total"></span>
+ <div class="cart_empty">
+ You have nothing in your cart.
</div>
</div>
</div>
diff --git a/StoneIsland/www/js/lib/cart/CartConfirm.js b/StoneIsland/www/js/lib/cart/CartConfirm.js
index 7d8c6568..687f3a93 100644
--- a/StoneIsland/www/js/lib/cart/CartConfirm.js
+++ b/StoneIsland/www/js/lib/cart/CartConfirm.js
@@ -5,7 +5,8 @@ var CartConfirm = FormView.extend({
events: {
},
- initialize: function(){
+ initialize: function(opt){
+ this.parent = opt.parent
this.scroller = new IScroll('#cart_confirm', app.iscroll_options)
},
diff --git a/StoneIsland/www/js/lib/cart/CartPayment.js b/StoneIsland/www/js/lib/cart/CartPayment.js
index bcca1915..a9772ffe 100644
--- a/StoneIsland/www/js/lib/cart/CartPayment.js
+++ b/StoneIsland/www/js/lib/cart/CartPayment.js
@@ -5,7 +5,8 @@ var CartPayment = FormView.extend({
events: {
},
- initialize: function(){
+ initialize: function(opt){
+ this.parent = opt.parent
this.$form = this.$("form")
this.$msg = this.$(".msg")
this.address = new AddressView ({ parent: this })
diff --git a/StoneIsland/www/js/lib/cart/CartShipping.js b/StoneIsland/www/js/lib/cart/CartShipping.js
index 65e2cb65..c0c21b4d 100644
--- a/StoneIsland/www/js/lib/cart/CartShipping.js
+++ b/StoneIsland/www/js/lib/cart/CartShipping.js
@@ -5,7 +5,8 @@ var CartShipping = FormView.extend({
events: {
},
- initialize: function(){
+ initialize: function(opt){
+ this.parent = opt.parent
this.$form = this.$("form")
this.$msg = this.$(".msg")
this.address = new AddressView ({ parent: this })
diff --git a/StoneIsland/www/js/lib/cart/CartSummary.js b/StoneIsland/www/js/lib/cart/CartSummary.js
index d8619990..290627d3 100644
--- a/StoneIsland/www/js/lib/cart/CartSummary.js
+++ b/StoneIsland/www/js/lib/cart/CartSummary.js
@@ -5,18 +5,42 @@ var CartSummary = ScrollableView.extend({
events: {
},
- initialize: function(){
+ initialize: function(opt){
+ this.parent = opt.parent
+ this.$loader = this.$(".loader")
+ this.$cart_body = this.$(".cart_body")
+ this.$cart_empty = this.$(".cart_empty")
this.scroller = new IScroll('#cart_summary', app.iscroll_options)
},
show: function(){
document.body.className = "cart"
app.cart.el.className = "summary"
+ this.$loader.show()
+
+ sdk.cart.get_status({
+ success: this.populate.bind(this),
+ error: this.error.bind(this),
+ })
+ },
+
+ populate: function(data){
+ this.$loader.hide()
app.footer.show("SHIPPING &gt;", "CANCEL")
+
+ console.log(data)
+
+ this.parent.$itemcount.html("1 ITEM")
+
+ this.$el.removeClass("empty").addClass("full")
this.deferScrollToTop()
},
- populate: function(){
+ error: function(){
+ this.$loader.hide()
+ app.footer.hide()
+ this.parent.$itemcount.html("0 ITEMS")
+ this.$el.addClass("empty").removeClass("full")
},
ok: function(){
diff --git a/StoneIsland/www/js/lib/cart/CartThanks.js b/StoneIsland/www/js/lib/cart/CartThanks.js
index 9524ab83..993fd9ac 100644
--- a/StoneIsland/www/js/lib/cart/CartThanks.js
+++ b/StoneIsland/www/js/lib/cart/CartThanks.js
@@ -5,7 +5,8 @@ var CartThanks = View.extend({
events: {
},
- initialize: function(){
+ initialize: function(opt){
+ this.parent = opt.parent
},
show: function(){
diff --git a/StoneIsland/www/js/lib/cart/CartView.js b/StoneIsland/www/js/lib/cart/CartView.js
index 43dc7dd4..fdad3a07 100644
--- a/StoneIsland/www/js/lib/cart/CartView.js
+++ b/StoneIsland/www/js/lib/cart/CartView.js
@@ -3,17 +3,19 @@ var CartView = View.extend({
el: "#cart",
events: {
- "click .summary": "show_summary",
- "click .shipping": "show_shipping",
- "click .payment": "show_payment",
+ "click .summary_step": "show_summary",
+ "click .shipping_step": "show_shipping",
+ "click .payment_step": "show_payment",
},
initialize: function(){
- this.summary = new CartSummary ()
- this.payment = new CartPayment ()
- this.shipping = new CartShipping ()
- this.confirm = new CartConfirm ()
- this.thanks = new CartThanks ()
+ this.summary = new CartSummary ({ parent: this })
+ this.payment = new CartPayment ({ parent: this })
+ this.shipping = new CartShipping ({ parent: this })
+ this.confirm = new CartConfirm ({ parent: this })
+ this.thanks = new CartThanks ({ parent: this })
+
+ this.$itemcount = this.$(".itemcount")
},
show: function(){
diff --git a/StoneIsland/www/js/sdk/auth.js b/StoneIsland/www/js/sdk/auth.js
index fe7acc5c..66dd81e8 100644
--- a/StoneIsland/www/js/sdk/auth.js
+++ b/StoneIsland/www/js/sdk/auth.js
@@ -82,6 +82,12 @@ var auth = sdk.auth = (function(){
}
auth.defer_add_to_cart = function(){
// auth.deferred_product
+ sdk.cart.add_item({
+ data: {
+ Code10: auth.deferred_product.code,
+ Size: auth.deferred_product.size,
+ }
+ })
}
auth.log_out = function(){
auth.clear_user()
diff --git a/StoneIsland/www/js/sdk/cart.js b/StoneIsland/www/js/sdk/cart.js
index cfa997cb..308231ff 100644
--- a/StoneIsland/www/js/sdk/cart.js
+++ b/StoneIsland/www/js/sdk/cart.js
@@ -90,8 +90,12 @@ sdk.cart = (function(){
"x-yoox-device": auth.device,
},
success: function(data){
- // console.log(data)
- opt.success(data)
+ if (data['Error']) {
+ opt.error && opt.error(data)
+ }
+ else {
+ opt.success(data)
+ }
},
error: opt.error,
})
@@ -106,7 +110,10 @@ sdk.cart = (function(){
"x-yoox-appname": auth.appname,
"x-yoox-cart-token": cart.token,
},
- data: opt.data,
+ data: {
+ "UserId": auth.user_id,
+ "UserToken": auth.access_token,
+ },
success: function(data){
// console.log(data)
opt.success(data)
diff --git a/test/test/04-cart.js b/test/test/04-cart.js
index 278949cc..d394b59f 100644
--- a/test/test/04-cart.js
+++ b/test/test/04-cart.js
@@ -63,11 +63,7 @@ describe('cart', function(){
})
describe('#get_status()', function(){
it('get contents of cart', function(done){
- var user_creds = {
- "UserId": sdk.auth.user_id,
- "UserToken": sdk.auth.access_token,
- }
- promise(sdk.cart.get_status, { data: user_creds }).then(function(data){
+ promise(sdk.cart.get_status, {}).then(function(data){
assert(data.Header.StatusCode == 200)
// console.log(data)
done()