summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib/cart/CartShipping.js
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/www/js/lib/cart/CartShipping.js')
-rw-r--r--StoneIsland/www/js/lib/cart/CartShipping.js42
1 files changed, 39 insertions, 3 deletions
diff --git a/StoneIsland/www/js/lib/cart/CartShipping.js b/StoneIsland/www/js/lib/cart/CartShipping.js
index 7236347f..d1e1a97e 100644
--- a/StoneIsland/www/js/lib/cart/CartShipping.js
+++ b/StoneIsland/www/js/lib/cart/CartShipping.js
@@ -2,6 +2,8 @@ var CartShipping = FormView.extend({
el: "#cart_shipping",
+ action: sdk.cart.set_shipping_address,
+
list_mode: true,
template: $("#cart_shipping .template").html(),
@@ -18,6 +20,7 @@ var CartShipping = FormView.extend({
this.$msg = this.$(".msg")
this.address = new AddressView ({ parent: this })
this.scroller = new IScroll('#cart_shipping', app.iscroll_options)
+ this.address.disabled = true
},
show: function(){
@@ -50,6 +53,7 @@ var CartShipping = FormView.extend({
toggle_dropdown: function(state){
this.list_mode = typeof state == "boolean" ? state : ! this.list_mode
+ this.address.disabled = this.list_mode
this.$address_form.toggle(! this.list_mode)
this.$address_list.toggle(this.list_mode)
},
@@ -58,16 +62,48 @@ var CartShipping = FormView.extend({
// sdk.shipping.get_delivery_types
// sdk.shipping.set_delivery_type
+ shipping_types: {
+ Standard: 1,
+ Express: 2,
+ },
+
finalize: function(data){
- console.log(data)
- return
+ var shipping_info = {}, address_data, address_id
+ var shipping_type = $("[name=ShippingType]").filter(function(){ return $(this).prop("checked") }).val()
+ sdk.shipping.set_delivery_type({
+ id: this.shipping_types[shipping_type],
+ success: function(data){ console.log("set shipping type", data) },
+ error: function(data){ console.log("didnt set shipping type", data) },
+ })
+
+ if (this.list_mode) {
+ address_id = $("[name=AddressId]").filter(function(){ return $(this).prop("checked") }).val()
+ address_data = app.account.addressLookup[ address_id ]
+ }
+ else {
+ address_data = data
+ }
+
+ shipping_info.Name = address_data.Name
+ shipping_info.Surname = address_data.Surname
+ shipping_info.Email = address_data.Name
+ shipping_info.Phone = address_data.Phone
+ shipping_info.Mobile = address_data.Phone
+ shipping_info.StreetWithNumber = address_data.Address
+ shipping_info.PostalCode = address_data.ZipCode
+ shipping_info.City = address_data.City
+ shipping_info.Region = address_data.Province
+ shipping_info.CountryCode = "US"
+
+ return address_data
},
success: function(){
+ app.router.go('cart/payment')
},
cancel: function(){
- app.cart.cart_summary.show()
+ app.router.go('cart/summary')
},
}) \ No newline at end of file