diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-11-23 19:52:41 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-11-23 19:52:41 -0500 |
| commit | e7703ca78d5b3f63a98f995c128db3a963eac7b4 (patch) | |
| tree | 976bedb17af3b67946573e4274177e7e2c0c9fca | |
| parent | 057742265e771dfd75ad9eddb3414e807e110995 (diff) | |
add to cart race condition
| -rw-r--r-- | StoneIsland/www/js/lib/account/AccountView.js | 2 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/auth/LoginView.js | 5 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/auth/SignupView.js | 5 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/cart/CartSummary.js | 6 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/products/ProductView.js | 24 | ||||
| -rw-r--r-- | StoneIsland/www/js/sdk/cart.js | 2 |
6 files changed, 29 insertions, 15 deletions
diff --git a/StoneIsland/www/js/lib/account/AccountView.js b/StoneIsland/www/js/lib/account/AccountView.js index e9022d64..cbd9a9c6 100644 --- a/StoneIsland/www/js/lib/account/AccountView.js +++ b/StoneIsland/www/js/lib/account/AccountView.js @@ -52,7 +52,7 @@ var AccountView = View.extend({ } else { if (auth.deferred_product) { - auth.add_deferred_product_to_cart( app.cart.load.bind(app.cart) ) + auth.add_deferred_product_to_cart() } else { app.cart.load() diff --git a/StoneIsland/www/js/lib/auth/LoginView.js b/StoneIsland/www/js/lib/auth/LoginView.js index b761b5e8..1f7438cc 100644 --- a/StoneIsland/www/js/lib/auth/LoginView.js +++ b/StoneIsland/www/js/lib/auth/LoginView.js @@ -16,10 +16,11 @@ var LoginView = FormView.extend({ }, show: function(){ - var msg = "* Your personal and payment<br>information will always remain private" if (auth.logged_in()) { - msg += "<br><br>You are already logged in." + app.router.go("intro") + return } + var msg = "* Your personal and payment<br>information will always remain private" app.footer.show("SUBMIT", "CANCEL") this.$form.get(0).reset() this.$msg.html(msg) diff --git a/StoneIsland/www/js/lib/auth/SignupView.js b/StoneIsland/www/js/lib/auth/SignupView.js index fe0e28db..5d947d41 100644 --- a/StoneIsland/www/js/lib/auth/SignupView.js +++ b/StoneIsland/www/js/lib/auth/SignupView.js @@ -29,10 +29,11 @@ var SignupView = FormView.extend({ }, show: function(){ - var msg = "* Your personal and payment<br>information will always remain private" if (auth.logged_in()) { - msg += "<br><br>You are already logged in." + app.router.go("intro") + return } + var msg = "* Your personal and payment<br>information will always remain private" app.footer.show("SUBMIT", "CANCEL") this.$form.get(0).reset() this.$msg.html(msg) diff --git a/StoneIsland/www/js/lib/cart/CartSummary.js b/StoneIsland/www/js/lib/cart/CartSummary.js index ce7ae650..7a5a1cfe 100644 --- a/StoneIsland/www/js/lib/cart/CartSummary.js +++ b/StoneIsland/www/js/lib/cart/CartSummary.js @@ -37,6 +37,7 @@ var CartSummary = ScrollableView.extend({ load: function(){ this.$loader.show() + app.footer.show("SHIPPING >", "CANCEL") sdk.cart.get_status({ success: this.populate.bind(this), error: this.empty.bind(this), @@ -45,9 +46,10 @@ var CartSummary = ScrollableView.extend({ populate: function(data){ this.data = data -console.log(data) + + console.log("CART", data) + this.$loader.hide() - app.footer.show("SHIPPING >", "CANCEL") this.update_counts() diff --git a/StoneIsland/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js index cf6c1a90..c99ff0ab 100644 --- a/StoneIsland/www/js/lib/products/ProductView.js +++ b/StoneIsland/www/js/lib/products/ProductView.js @@ -211,11 +211,16 @@ var ProductView = ScrollableView.extend({ app.last_view = app.cart } else if ( ! auth.has_cart() ) { - auth.create_cart(auth.add_deferred_product_to_cart) + auth.create_cart(function(){ + auth.add_deferred_product_to_cart(function(){ + app.router.go("cart") + }) + }) } else { - app.go("cart") - auth.add_deferred_product_to_cart() + auth.add_deferred_product_to_cart(function(){ + app.router.go("cart") + }) } }, @@ -223,15 +228,20 @@ var ProductView = ScrollableView.extend({ cancel: function(){ auth.deferred_product = { Size: this.size, Code10: this.code } if ( ! auth.logged_in() ) { - app.go("account/login") + app.router.go("account/login") app.last_view = app.cart } else if ( ! auth.has_cart() ) { - auth.create_cart(auth.add_deferred_product_to_cart) + auth.create_cart(function(){ + auth.add_deferred_product_to_cart(function(){ + app.router.go("cart") + }) + }) } else { - app.go("cart") - auth.add_deferred_product_to_cart() + auth.add_deferred_product_to_cart(function(){ + app.router.go("cart") + }) } }, diff --git a/StoneIsland/www/js/sdk/cart.js b/StoneIsland/www/js/sdk/cart.js index 3f53d9d5..bbd03299 100644 --- a/StoneIsland/www/js/sdk/cart.js +++ b/StoneIsland/www/js/sdk/cart.js @@ -83,7 +83,7 @@ sdk.cart = (function(){ cart.get_status = function(opt){ if (! cart.id) { - return opt.error() + return opt.error({ error: "no cart" }) } return $.ajax({ method: "GET", |
