summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib/products/ProductView.js
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/www/js/lib/products/ProductView.js')
-rwxr-xr-xStoneIsland/www/js/lib/products/ProductView.js57
1 files changed, 47 insertions, 10 deletions
diff --git a/StoneIsland/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js
index 9ce4a1f3..72ff9da3 100755
--- a/StoneIsland/www/js/lib/products/ProductView.js
+++ b/StoneIsland/www/js/lib/products/ProductView.js
@@ -224,6 +224,7 @@ var ProductView = ScrollableView.extend({
sizes[ size['SizeId'] ] = {
id: label,
label: label.toUpperCase(),
+ value: size['SizeId'],
colors: {},
}
})
@@ -246,6 +247,7 @@ var ProductView = ScrollableView.extend({
}.bind(this))
app.selector.select("style", sizes, function(size){
+ console.log(size)
this.size = size.value
this.$size.html(size.label)
}.bind(this))
@@ -277,27 +279,62 @@ var ProductView = ScrollableView.extend({
},
add_to_cart: function(opt){
- auth.deferred_product = { Size: this.size, Code10: this.code }
+ var deferred_product = auth.deferred_product = { Size: this.size, Code10: this.code }
+ console.log("ADDING " + this.size + " " + this.code )
+ // if we are not logged in...
if ( ! auth.logged_in() ) {
app.router.go("account/login")
app.last_view = app.cart
}
+ // if we don't have a cart setup...
else if ( ! auth.has_cart() ) {
app.curtain.show("loading")
- auth.create_cart(function(){
- auth.add_deferred_product_to_cart(function(){
+ auth.create_cart({
+ success: function(){
+ auth.add_deferred_product_to_cart({
+ success: function(){
+ app.curtain.hide("loading")
+ app.router.go("cart")
+ },
+ error: function(){
+ // SHOULD NOT BE A PROBLEM
+ console.log("ERROR ADDING PRODUCT TO NEW CART SIMPLE ADD TO CART")
+ app.curtain.hide("loading")
+ app.router.go("account/login")
+ auth.deferred_product = deferred_product
+ app.last_view = app.cart
+ },
+ })
+ },
+ error: function(){
+ // ERROR CREATING CART?
+ console.log("ERROR CREATING CART")
+ auth.log_out()
+ app.account.logged_out()
app.curtain.hide("loading")
- app.router.go("cart")
- })
+ app.router.go("account/login")
+ auth.deferred_product = deferred_product
+ app.last_view = app.cart
+ },
})
}
else {
app.curtain.show("loading")
- auth.add_deferred_product_to_cart(function(){
- app.curtain.hide("loading")
- if (opt.route) {
- app.router.go("cart")
- }
+ auth.add_deferred_product_to_cart({
+ success: function(){
+ app.curtain.hide("loading")
+ if (opt.route) {
+ app.router.go("cart")
+ }
+ },
+ error: function(){
+ console.log("CART MIGHT BE OLD")
+ // TODO - CART MIGHT BE OLD
+ app.curtain.hide("loading")
+ app.router.go("account/login")
+ auth.deferred_product = deferred_product
+ app.last_view = app.cart
+ },
})
}
},