Refactoring the way we default shipping_method_id

This commit is contained in:
Will Marshall
2014-03-05 15:49:47 +11:00
parent 3c108d3366
commit 7d0fdead7a
2 changed files with 6 additions and 9 deletions

View File

@@ -5,6 +5,11 @@ angular.module("Checkout").controller "CheckoutCtrl", ($scope, $rootScope, order
$scope.same_as_billing = true
$scope.order = order
# Our shipping_methods comes through as a hash like so: {id: requires_shipping_address}
# Here we default to the first shipping method if none is selected
$scope.order.shipping_method_id ||= Object.keys(order.shipping_methods)[0]
$scope.require_ship_address = $scope.order.shipping_methods[$scope.order.shipping_method_id]
$scope.shippingMethodChanged = ->