Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| snippets:shipping:restricting_countries_and_states_on_the_checkout_old [2012/10/08 05:11] – Document moved from snippets:shipping:restricing_countries_and_states_on_the_checkout_old adam | snippets:shipping:restricting_countries_and_states_on_the_checkout_old [2019/01/14 00:55] (current) – adam | ||
|---|---|---|---|
| Line 16: | Line 16: | ||
| + | <WRAP center round important> | ||
| + | **Using version 2.0?** There is native functionality that covers this snippet within the configuration section of the administration. There is also a new snippet available for our latest version, [[v: | ||
| + | </ | ||
| ====== Restricting countries from the checkout | ====== Restricting countries from the checkout | ||
| Line 63: | Line 66: | ||
| FC.checkout.setAutoComplete(" | FC.checkout.setAutoComplete(" | ||
| }); | }); | ||
| + | </ | ||
| + | |||
| + | ==== Restricting the country dropdown to a subset of countries ==== | ||
| + | |||
| + | Often you'll need to ship to only a few countries, like perhaps just the US and Canada. In that case, the following javascript will help you do that. Just change the '' | ||
| + | |||
| + | <code javascript> | ||
| + | <script type=" | ||
| + | jQuery(document).ready(function(){ | ||
| + | var newCountries = []; | ||
| + | var includeCountries = [" | ||
| + | for (var i = 0; i < FC.locations.config.locations.length; | ||
| + | if (jQuery.inArray(FC.locations.config.locations[i].cc2, | ||
| + | newCountries.push(FC.locations.config.locations[i]; | ||
| + | } | ||
| + | } | ||
| + | FC.locations.config.locations = newCountries; | ||
| + | FC.checkout.setAutoComplete(" | ||
| + | FC.checkout.setAutoComplete(" | ||
| + | FC.checkout.setAutoComplete(" | ||
| + | FC.checkout.setAutoComplete(" | ||
| + | }); | ||
| + | </ | ||
| </ | </ | ||
| Line 89: | Line 115: | ||
| } | } | ||
| } | } | ||
| - | var newregions = FC.locations.config.locations[usIndex].r; | + | var newregions = []; |
| for (var i = 0; i < FC.locations.config.locations[usIndex].r.length; | for (var i = 0; i < FC.locations.config.locations[usIndex].r.length; | ||
| - | if (FC.locations.config.locations[usIndex].r[i].c | + | if (FC.locations.config.locations[usIndex].r[i].c |
| - | newregions.splice(i,1); | + | newregions.push(FC.locations.config.locations[usIndex].r[i]); |
| } | } | ||
| } | } | ||
| Line 103: | Line 129: | ||
| </ | </ | ||
| </ | </ | ||
| - | |||
| ===== Related Forum Discussions ===== | ===== Related Forum Discussions ===== | ||
| * http:// | * http:// | ||