Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chucktrukk/502971 to your computer and use it in GitHub Desktop.
Save chucktrukk/502971 to your computer and use it in GitHub Desktop.
<script type="text/javascript" charset="utf-8">
jQuery(document).ready(function(){
// Set the indexes for the countries you want to allow
var usIndex = -1;
var caIndex = -1;
// Find their positions in the array using the 2 character ISO code
for (var i = 0; i < FC.locations.config.locations.length; i++) {
if (FC.locations.config.locations[ i ].cc2 == "US") {
usIndex = i;
} else if (FC.locations.config.locations[ i ].cc2 == "CA") {
caIndex = i;
}
}
// If they're found, create a new temp object to replace the default object with
if (usIndex != -1 && caIndex != -1) {
var tempLocations = [
FC.locations.config.locations[usIndex],
FC.locations.config.locations[caIndex]
];
var tempCountries = [
FC.locations.config.countries[usIndex],
FC.locations.config.countries[caIndex]
];
FC.locations.locations = tempLocations;
FC.locations.countries = tempCountries;
FC.checkout.setAutoComplete("customer_country");
FC.checkout.setAutoComplete("customer_state");
FC.checkout.setAutoComplete("shipping_country");
FC.checkout.setAutoComplete("shipping_state");
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment