diff options
Diffstat (limited to 'StoneIsland/www/js/sdk/auth.js')
| -rw-r--r-- | StoneIsland/www/js/sdk/auth.js | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/StoneIsland/www/js/sdk/auth.js b/StoneIsland/www/js/sdk/auth.js index 66dd81e8..65505d81 100644 --- a/StoneIsland/www/js/sdk/auth.js +++ b/StoneIsland/www/js/sdk/auth.js @@ -24,7 +24,9 @@ var auth = sdk.auth = (function(){ // android: cordova.file.externalRootDirectory api auth.init = function(fn){ + console.log("AUTH INIT") auth.get_user(function(){ + console.log("cool") if (auth.logged_in()) { auth.get_cart() } @@ -71,34 +73,41 @@ var auth = sdk.auth = (function(){ cb && cb() } auth.create_cart = function(cb){ - if (auth.has_cart) { return cb() } - sdk.cart.initialize().done(function(){ - sdk.cart.set_user().done(function(){ - auth.set_cart(sdk.cart.id, sdk.cart.token, function(){ - cb && cb() + if (auth.has_cart()) { return cb() } + sdk.cart.initialize({ + success: function(data){ + sdk.cart.set_user({ + success: function(){ + auth.set_cart(sdk.cart.id, sdk.cart.token, function(){ + cb && cb() + }) + } }) - }) + } }) } - auth.defer_add_to_cart = function(){ + auth.add_deferred_product_to_cart = function(){ // auth.deferred_product sdk.cart.add_item({ - data: { - Code10: auth.deferred_product.code, - Size: auth.deferred_product.size, + data: auth.deferred_product, + success: function(){ + console.log("ADDED") } }) + auth.deferred_product = null + app.header.increment_cart_count() } + auth.log_out = function(){ auth.clear_user() auth.clear_cart() auth.view_logged_out() } auth.logged_in = function(){ - return (auth.user_id !== -1) + return (auth.user_id !== -1) && (auth.user_id !== "undefined") } auth.has_cart = function(){ - return (cart.id !== -1) + return (sdk.cart.id !== -1) && (sdk.cart.id !== "undefined") } return auth |
