Finally fixing the same as billing address checkbox?

This commit is contained in:
Will Marshall
2014-03-13 11:41:46 +11:00
parent e7bed58616
commit 1ba720481f
4 changed files with 9 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ angular.module("Checkout").controller "CheckoutCtrl", ($scope, $rootScope, order
# Here we default to the first shipping method if none is selected
$scope.order.shipping_method_id ||= Object.keys(order.shipping_methods)[0]
$scope.order.ship_address_same_as_billing = true if $scope.order.ship_address_same_as_billing == null
$scope.require_ship_address = $scope.order.shipping_methods[$scope.order.shipping_method_id]
$scope.shippingMethodChanged = ->

View File

@@ -65,6 +65,12 @@ Spree::Order.class_eval do
where("state != ?", state)
}
# Accessors
#
def ship_address_same_as_billing=(string_value)
@ship_address_same_as_billing = (string_value == "true")
end
# -- Methods
def products_available_from_new_distribution

View File

@@ -73,6 +73,7 @@
#ship_address{"ng-show" => "require_ship_address"}
%label
= hidden_field_tag "order[ship_address_same_as_billing]", "false"
= check_box_tag "order[ship_address_same_as_billing]", true, @order.ship_address_same_as_billing,
"ng-model" => "order.ship_address_same_as_billing"
Shipping address same as billing address?

View File

@@ -1,8 +1,5 @@
object current_order
attributes :id, :email, :shipping_method_id
node :ship_address_same_as_billing do
current_order.ship_address_same_as_billing == "true"
end
attributes :id, :email, :shipping_method_id, :ship_address_same_as_billing
child current_order.bill_address => :bill_address do
attributes :phone, :firstname, :lastname, :address1, :address2, :city, :country_id, :state_id, :zipcode