Hi @natekinkead,
I got it to work, needed to modify autocomplete.js a bit, the country is Indonesia (ID) btw.
formFields : {
'billing_address_1': '',
'billing_address_2': '',
'billing_kelurahan': '',
'billing_kecamatan': '',
'billing_city': '',
'billing_state': '',
'billing_postcode': '',
'billing_country' : ''
},
formFieldsValue : {
'billing_address_1': '',
'billing_address_2': '',
'billing_kelurahan': '',
'billing_kecamatan': '',
'billing_city': '',
'billing_state': '',
'billing_postcode': '',
'billing_country' : ''
},
And another one.
this.component_form =
{
'street_number': ['billing_address_1', 'short_name'],
'route': ['billing_address_1', 'long_name'],
'administrative_area_level_4': ['billing_kelurahan', 'short_name'],
'administrative_area_level_3': ['billing_kecamatan', 'short_name'],
'administrative_area_level_2': ['billing_city', 'long_name'],
'administrative_area_level_1': ['billing_state', 'short_name'],
'country': ['billing_country', 'long_name'],
'postal_code': ['billing_postcode', 'short_name']
};
Please disregard the “kelurahan” and “kecamatan” fields, as they’re my custom fields.
Also, since the “billing_state” field is a dropdown, and I only use 3 of the states, I added this code.
var prop = this.component_form[f][1];
if(place.address_components[field].hasOwnProperty(prop)){
if (b_city_valid) {
if (place.address_components[field][prop] == "Daerah Khusus Ibukota Jakarta") place.address_components[field][prop] = "JK";
if (place.address_components[field][prop] == "Jawa Barat") place.address_components[field][prop] = "JB";
if (place.address_components[field][prop] == "Banten") place.address_components[field][prop] = "BT";
this.formFieldsValue[this.component_form[f][0]] = place.address_components[field][prop];
// console.log(this.component_form[f][0] + " = " + place.address_components[field][prop]);
}
}
This has to be done for both billing and shipping. But it’s working now.
Thanks,
Dicko