diff --git a/app/helpers/checkout_helper.rb b/app/helpers/checkout_helper.rb index f5c10c3649..e47b393998 100644 --- a/app/helpers/checkout_helper.rb +++ b/app/helpers/checkout_helper.rb @@ -25,6 +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] } + end + + def checkout_country_options + available_countries.map { |c| [c.name, c.id] } + end + def validated_input(name, path, args = {}) attributes = { diff --git a/app/views/checkout/_billing.html.haml b/app/views/checkout/_billing.html.haml index c1cafa6161..07faa3d442 100644 --- a/app/views/checkout/_billing.html.haml +++ b/app/views/checkout/_billing.html.haml @@ -39,13 +39,13 @@ = validated_input "City", "order.bill_address.city" .small-6.columns - = validated_select "State", "order.bill_address.state_id", [[]]+@order.billing_address.country.states.map{|c|[c.name, c.id]} + = validated_select "State", "order.bill_address.state_id", checkout_state_options .row .small-6.columns = validated_input "Postcode", "order.bill_address.zipcode" .small-6.columns.right - = ba.select :country_id, available_countries.map{|c|[c.name, c.id]}, + = ba.select :country_id, checkout_country_options, "ng-model" => "order.bill_address.country_id", required: true .row