Created
January 28, 2010 20:15
-
-
Save brettflorio/289097 to your computer and use it in GitHub Desktop.
JavaScript to restrict the autocomplete arrays on the FoxyCart v060 checkout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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