summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js')
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js194
1 files changed, 0 insertions, 194 deletions
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js
deleted file mode 100755
index 6909dcc3..00000000
--- a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js
+++ /dev/null
@@ -1,194 +0,0 @@
-var CartConfirm = FormView.extend({
-
- el: "#cart_confirm",
-
- template: $("#cart_confirm .template").html(),
-
- events: {
- },
-
- initialize: function(opt){
- this.parent = opt.parent
- this.$rows = this.$(".rows")
- this.$subtotal = this.$(".subtotal")
- this.$shipping = this.$(".shipping")
- this.$tax = this.$(".tax")
- this.$total = this.$(".total")
-
- this.$shipping_address = this.$(".shipping_address")
- this.$shipping_method = this.$(".shipping_method")
-
- this.$payment_name = this.$(".payment_name")
- this.$payment_method = this.$(".payment_method")
- this.$payment_address = this.$(".payment_address")
-
- this.scroller = ScrollFactory('#cart_confirm', app.iscroll_options)
- },
-
- show: function(){
- document.body.className = "cart"
- app.cart.el.className = "confirm"
- app.footer.show("PLACE ORDER")
- window.location.hash = "#/cart/confirm"
- this.deferScrollToTop()
-
- app.view = this
- app.curtain.show("loading")
- promise(sdk.cart.get_status).then( this.populate.bind(this) )
- },
-
- populate: function(data){
- console.log(data)
-
- data = data.Cart
-
- this.$rows.empty()
-
- data.Items.forEach(function(item){
- var $el = $("<div class='item'><img src='img/spinner.gif'></div>")
- this.$rows.append($el)
- var code_ten = item.Code10
- var size_id = item.Size
-
- var code = code_ten.substr(0, 8)
- app.product.find(code, function(data, details){
- var descriptions = app.product.get_descriptions( details )
-
- var name_partz = descriptions['ModelNames'].split(' ')
- var num = name_partz.shift()
- var title = name_partz.join(' ')
- var type = title_case( descriptions['MicroCategory'] )
-
- var color_name, size_name
-
- details.Item.ModelColors.some(function(color){
- if (color['Code10'] == code_ten) {
- color_name = color['ColorDescription']
- return true
- }
- return false
- })
-
- details.Item.ModelSizes.some(function(size){
- if (size['SizeId'] == size_id) {
- // console.log(size)
- size_name = size['Default']['Text']
- size_name = SIZE_LOOKUP[ size_name ] || size_name
- if (! size_name && ! size['Default']['Labeled']) {
- size_name = size['Default']['Text'] + " " + size['Default']['ClassFamily']
- }
-
- return true
- }
- return false
- })
-
-// size_name = item.DefaultSize + " " + item.DefaultSizeClassFamily
-
- var t = this.template
- .replace(/{{image}}/, sdk.image(item['Code10'], '11_f'))
- .replace(/{{sku}}/, num)
- .replace(/{{title}}/, title)
- .replace(/{{type}}/, type)
- .replace(/{{size}}/, size_name || "DEFAULT")
- .replace(/{{color}}/, color_name || "DEFAULT")
- .replace(/{{quantity}}/, 1)
- .replace(/{{price}}/, as_cash(details.Item.Price.DiscountedPrice))
- $el.data("price", details.Item.Price.DiscountedPrice)
- $el.html(t)
- this.refreshScroller()
- }.bind(this))
- }.bind(this))
-
- var subtotal = data.Totals.TotalWithoutPromotions
- var shipping_cost = data.DeliveryMethod.Selected.Amount.Total
- var tax = data.Totals.TotalSalesTax
- var total = data.Totals.TotalToPay
-
- this.$subtotal.html( as_cash(subtotal) )
- this.$shipping.html( as_cash(shipping_cost) )
- this.$tax.html( as_cash(tax) )
- this.$total.html( as_cash(total) )
-
- 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")
- } else {
- this.$shipping_address.html( "Please enter your shipping information." )
- this.$shipping_method.html( "" )
- }
-
- var cc = data.Payment.CreditCard
- 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( "" )
- }
-
- app.curtain.hide("loading")
- },
-
- save: function(){
- app.curtain.show("loading")
- promise(sdk.cart.finalize, {}).then(function(){
- app.curtain.hide("loading")
- app.router.go('cart/thanks')
- }.bind(this)).error(function(res){
- const data = res.responseJSON
- console.log(data)
- app.curtain.hide("loading")
- // {"Header":{"StatusCode":403,"Description":"403 Forbidden"},"Error":{"Description":"GenericApiError:CartAlreadyClosed"}}
- // {"Header":{"StatusCode":409,"Description":"304 NotModified"},"Error":{"Description":"FinalizationError:\\"Item has been removed from cart because it is no longer available.\\"\\n235"}}'
- // {"Header":{"StatusCode":409,"Description":"304 NotModified"},"Error":{"Description":"FinalizationError:\"The cart cannot be empty.\"\n233"}}
- // {"Header":{"StatusCode":409,"Description":"304 NotModified"},"Error":{"Description":"FinalizationError:\"The reciever validation fails."}}
- // {"Header":{"StatusCode":440,"Description":"304 NotModified"},"Error":{"Description":"GenericApiError:CartFinalizationNotYetCompleted"}}
- // {"Header":{"StatusCode":441,"Description":"304 NotModified"},"Error":{"Description":"GenericApiError:EmptyCreditCard"}}
- switch (data.StatusCode || data.Header.StatusCode) {
- case 403: // cart already closed
- auth.clear_cart(auth.create_cart)
- app.router.go('thanks')
- break
- case 409: // finalization error
- this.finalization_error(data)
- break
- case 440: // genericapierror (credit card error!)
- case 441: // genericapierror (credit card empty)
- app.router.go('cart/payment')
- app.cart.payment.show_errors([["Number","There was a problem with your credit card."]])
- break
- }
- }.bind(this))
- },
-
- finalization_error: function(data){
- 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/i)) {
- console.log('cart empty')
- app.router.go('cart/summary')
- }
- 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.")
- }
- },
-
- cancel: function(){
- app.router.go('cart/payment')
- },
-
-}) \ No newline at end of file