diff options
Diffstat (limited to 'StoneIsland/www/js/lib/cart/CartConfirm.js')
| -rwxr-xr-x | StoneIsland/www/js/lib/cart/CartConfirm.js | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/StoneIsland/www/js/lib/cart/CartConfirm.js b/StoneIsland/www/js/lib/cart/CartConfirm.js index 7f7d49b2..031e3359 100755 --- a/StoneIsland/www/js/lib/cart/CartConfirm.js +++ b/StoneIsland/www/js/lib/cart/CartConfirm.js @@ -110,28 +110,37 @@ var CartConfirm = FormView.extend({ this.$tax.html( as_cash(tax) ) this.$total.html( as_cash(total) ) - var street = data.Receiver.StreetWithNumber.replace(/\n$/,"").replace("\n", ", ") - var address = data.Receiver.Name.toUpperCase() + " " + data.Receiver.Surname.toUpperCase() + "<br>" + street + ", " - address += data.Receiver.City + ", " + data.Receiver.Region + " " + data.Receiver.PostalCode + if (data.Receiver) { + var street = data.Receiver.StreetWithNumber.replace(/\n$/,"").replace("\n", ", ") + var address = data.Receiver.Name.toUpperCase() + " " + data.Receiver.Surname.toUpperCase() + "<br>" + street + ", " + address += data.Receiver.City + ", " + data.Receiver.Region + " " + data.Receiver.PostalCode - this.$shipping_address.html(address) - this.$shipping_method.html(data.DeliveryMethod.Selected.Type == 1 ? "* STANDARD SHIPPING" : "* EXPRESS SHIPPING") + this.$shipping_address.html(address) + this.$shipping_method.html(data.DeliveryMethod.Selected.Type == 1 ? "* STANDARD SHIPPING" : "* EXPRESS SHIPPING") + } else { + this.$shipping_address.html( "Please enter your shipping information." ) + this.$shipping_method.html( "" ) + } var cc = data.Payment.CreditCard - var cc_street = cc ? cc.HolderAddress.replace(/\n$/,"").replace("\n", ", ") : "" - var cc_type = cc ? cc.Type == "AmericanExpress" ? "American Express" : cc.Type : "" - var cc_name = cc ? cc.HolderName.toUpperCase() + " " + cc.HolderSurname.toUpperCase() : "" - var cc_eNcrYpTed = cc ? cc_type.toUpperCase() + " XXXX-XXXX-XXXX-" + cc.Last4 : "" + if (cc) { + var cc_street = cc.HolderAddress.replace(/\n$/,"").replace("\n", ", ") + var cc_type = cc.Type == "AmericanExpress" ? "American Express" : cc.Type + var cc_name = cc.HolderName.toUpperCase() + " " + cc.HolderSurname.toUpperCase() + var cc_eNcrYpTed = cc_type.toUpperCase() + " XXXX-XXXX-XXXX-" + cc.Last4 + this.$payment_name.html( cc_name ) + this.$payment_method.html( cc_eNcrYpTed ) + } else { + this.$payment_name.html( "Please enter your credit card information." ) + this.$payment_method.html( "" ) + } - this.$payment_name.html( cc_name ) - this.$payment_method.html( cc_eNcrYpTed ) - app.curtain.hide("loading") }, save: function(){ app.curtain.show("loading") - promise(sdk.cart.secure_finalize, {}).then(function(){ + promise(sdk.cart.finalize, {}).then(function(){ app.curtain.hide("loading") app.router.go('cart/thanks') }.bind(this)).error(function(res){ @@ -162,14 +171,17 @@ var CartConfirm = FormView.extend({ }, finalization_error: function(data){ - if (data['Error']['Description'].match(/receiver validation fails/)) { - app.router.go('cart/shipping') + if (data['Error']['Description'].match(/receiver validation fails/i)) { + console.log('cc error') + app.router.go('cart/billing') app.cart.payment.show_errors([["Number","There was a problem with your credit card."]]) } - else if (data['Error']['Description'].match(/cart cannot be empty/)) { + else if (data['Error']['Description'].match(/cart cannot be empty/i)) { + console.log('cart empty') app.router.go('cart/summary') } - else if (data['Error']['Description'].match(/Item has been removed/)) { + else if (data['Error']['Description'].match(/Item has been removed/i)) { + console.log('item does not exist') app.router.go('cart/error') app.cart.error.show_error("We're sorry, but one or more items was out of stock. Please check your cart and try again.") } |
