Billing address state/province list setting

eriomagnoni
New Member
1 0 0

Hello,

I am trying to pre-populate the billing address same as shipping address during checkout, as soon as the customer clicks on the 'different billing address' button. Everything works fine except for the province/state dropdown which is not generated correctly. Seems like this list is getting generated for each country when the onchange event occurs on the country list. By setting same country at the shipping phase, I am unable to let this trigger work and the province/state list is generated from the first entity present in the customers address book. Do you have any idea?

I tried this in checkout.liquid inside the {{ checkout_scripts }} section:

-----

{{ '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js' | script_tag }}
 
    <script>
      $(document).ready(function() {
            $('.field--different-billing-address label').click();
            $("#checkout_billing_address_first_name").val('{{checkout.shipping_address.first_name}}');
            $("#checkout_billing_address_second_name").val('{{checkout.shipping_address.second_name}}');
            $("#checkout_billing_address_company").val('{{checkout.shipping_address.company}}');
            $("#checkout_billing_address_address1").val('{{checkout.shipping_address.address1}}');
            $("#checkout_billing_address_city").val('{{checkout.shipping_address.city}}');                                        
            $("#checkout_billing_address_country option[data-code={{checkout.shipping_address.country_code}}]").attr('selected', 'selected'); 
 
            --> something I should do for the state/province dropdown list <--
 
            $("#checkout_billing_address_zip").val('{{checkout.shipping_address.zip}}');
            $("#checkout_billing_address_phone").val('{{checkout.shipping_address.phone}}');                                       
});
</script>

-----

Cheers, Erio

0 Likes