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 [2013/07/22 12:09] – [Step 1: Add javascript] 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 91: | Line 117: | ||
| var newregions = []; | 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.push(FC.locations.config.locations[usIndex].r[i]); | newregions.push(FC.locations.config.locations[usIndex].r[i]); | ||
| } | } | ||