Forked from brettflorio/FoxyCart: Restrict countries on checkout autocompleter
Created
January 29, 2010 02:34
-
-
Save chucktrukk/289395 to your computer and use it in GitHub Desktop.
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.config.locations = tempLocations; | |
FC.locations.config.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