diff --git a/app/helpers/checkout_helper.rb b/app/helpers/checkout_helper.rb index e47b393998..1e672a0adc 100644 --- a/app/helpers/checkout_helper.rb +++ b/app/helpers/checkout_helper.rb @@ -25,8 +25,14 @@ module CheckoutHelper order.display_item_total.money.to_f + checkout_adjustments_total(order).money.to_f end - def checkout_state_options - [[]] + @order.billing_address.country.states.map { |c| [c.name, c.id] } + def checkout_state_options(source_address) + if source_address == :billing + address = @order.billing_address + elsif source_address == :shipping + address = @order.shipping_address + end + + [[]] + address.country.states.map { |c| [c.name, c.id] } end def checkout_country_options diff --git a/app/views/checkout/_billing.html.haml b/app/views/checkout/_billing.html.haml index 14821d0f37..c2573eef47 100644 --- a/app/views/checkout/_billing.html.haml +++ b/app/views/checkout/_billing.html.haml @@ -39,7 +39,7 @@ = validated_input "City", "order.bill_address.city" .small-6.columns - = validated_select "State", "order.bill_address.state_id", checkout_state_options + = validated_select "State", "order.bill_address.state_id", checkout_state_options(:billing) .row .small-6.columns = validated_input "Postcode", "order.bill_address.zipcode" diff --git a/app/views/checkout/_shipping.html.haml b/app/views/checkout/_shipping.html.haml index 9183f588f8..8e4ca9421b 100644 --- a/app/views/checkout/_shipping.html.haml +++ b/app/views/checkout/_shipping.html.haml @@ -66,14 +66,12 @@ .small-6.columns = validated_input "City", "order.ship_address.city" .small-6.columns - = sa.select :state_id, @order.shipping_address.country.states.map{|c|[c.name, c.id]}, {include_blank: false}, - "ng-model" => "order.ship_address.state_id", required: true + = validated_select "State", "order.ship_address.state_id", checkout_state_options(:shipping) .row .small-6.columns = validated_input "Postcode", "order.ship_address.zipcode" .small-6.columns.right - = sa.select :country_id, available_countries.map{|c|[c.name, c.id]}, - "ng-model" => "order.ship_address.country_id", required: true + = validated_select "Country", "order.ship_address.country_id", checkout_country_options .row .small-6.columns