php – Returns WooCommerce state / province option as selected in autocomplete plugin


I have installed a form autofill plugin that uses the Google Maps API to automatically fill in the WooCommerce payment form. One drawback it has is that it doesn't automatically select the state / province from the selection drop-down menu. Highlights the correct state in the drop-down options, but does not automatically return that state as selected in the State / County selector. This causes an additional problem in the sense that if you manually click the drop-down menu and click the highlighted state option, that state will not complete as selected. It does this for both billing and shipping.

I've looked at the JS for this plugin and I don't see where the problem lies, although it is clearly related to billing_state. Is there a way to force this code to return the highlighted option as selected instead of just highlighting it?

var Cas_billing=Cas_billing||{},Cas_shipping=Cas_shipping||{};if(Cas_billing.event={},Cas_shipping.event={},Cas_billing.method={searchAddress:"",seprateIds:"",sugessions:"",streetNumber:"",formFields:{billing_address_1:"",billing_address_2:"",billing_city:"",billing_state:"",billing_postcode:"",billing_country:""},formFieldsValue:{billing_address_1:"",billing_address_2:"",billing_city:"",billing_state:"",billing_postcode:"",billing_country:""},component_form:"",initialize:function(){this.getseprateIds(),this.initFormFields(),this.sugessions=new google.maps.places.Autocomplete(document.getElementById("billing_address_1"),{types:("geocode")}),google.maps.event.addListener(this.sugessions,"place_changed",function(){Cas_billing.method.fillInAddress()});var e=document.getElementById("billing_address_1");null!=e&&e.addEventListener("focus",function(){Cas_billing.method.setCurrentCountry()},!0);var s=document.getElementById("billing_country");null!=s&&s.addEventListener("change",function(){Cas_billing.method.setCurrentCountry()},!0)},getseprateIds:function(){return document.getElementById("billing_address_1")?(this.seprateIds=":",":"):(this.seprateIds="_","_")},initFormFields:function(){for(var e in this.formFields)this.formFields(e)=e;this.component_form={street_number:("billing_address_1","short_name"),route:("billing_address_1","long_name"),locality:("billing_city","long_name"),administrative_area_level_1:("billing_state","short_name"),country:("billing_country","long_name"),postal_code:("billing_postcode","short_name")}},fillInAddress:function(){this.clearFormValues(),this.sugessions.setFields(("address_components"));var e=this.sugessions.getPlace();for(var s in this.resetForm(),e.address_components)for(var t in e.address_components(s).types)for(var n in this.component_form){if(n==e.address_components(s).types(t)){"street_number"==n?this.streetNumber=e.address_components(s).short_name:"KR"==document.getElementById("billing_country").value&&(this.streetNumber=e.address_components(0).short_name,this.streetNumber+=","+e.address_components(1).long_name);var i=this.component_form(n)(1);e.address_components(s).hasOwnProperty(i)&&(this.formFieldsValue(this.component_form(n)(0))=e.address_components(s)(i))}}this.appendStreetNumber(),this.fillForm(),$=jQuery.noConflict(),$("#billing_state").trigger("change"),"undefined"!=typeof FireCheckout&&checkout.update(checkout.urls.billing_address)},clearFormValues:function(){for(var e in this.formFieldsValue)this.formFieldsValue(e)=""},appendStreetNumber:function(){""!=this.streetNumber&&(this.formFieldsValue.billing_address_1=this.streetNumber+" "+this.formFieldsValue.billing_address_1)},fillForm:function(){for(var e in this.formFieldsValue)if("billing_country"==e)this.selectRegion(e,this.formFieldsValue(e));else{if(null===document.getElementById(e))continue;document.getElementById(e).value=this.formFieldsValue(e)}},selectRegion:function(e,s){if(null==document.getElementById(e))return!1;for(var t=document.getElementById(e),n=0;n