Address Countries
If you want to filter the countries options shown in the address field you can use this filter.
Filter Hook name: surecart_address_countries
This is a JavaScript filter and must be loaded through a script on the frontend and in the footer.
You can use plugins such as Simple Custom CSS and JS, which allow you to easily add custom scripts.
For reference, see a screenshot demonstrating filter usage within the Simple Custom CSS and JS plugin: https://bsf.d.pr/i/CtABbJ
Filter Usage Example:
In the example below, we are adding two countries only.
wp.hooks.addFilter(
'surecart_address_countries', // Hook name.
'testnamespace', // Any custom namespace.
(countries) => {
const newCountries = [
{
value: 'US',
label: 'United States'
},
{
value: 'IN',
label: 'India'
}
];
return newCountries;
});
This filter can be used to remove countries, translate country names, or otherwise modify the countries array as needed.
Note:
The countries array you return must be an array of objects. Each country object in the array should contain only the label and value key-value pairs.
Updated about 13 hours ago