Country dropdown is very useful for redirecting country specific website on selection of a country from dropdown.
Here we take an use-case of redirect to Amazon India website https://www.amazon.in/ on selecting the india from dropdown.
To use country dropdown we should add the dropdown shortcode at the required place and then create a Redirect Rule based on the dropdown value.
How to Add Country dropdown: Login to your website admin console, click on dashboard and from left menu select Appearances and click on Editor.
Edit Theme page will be opened, click on the header.php add below line.
Add after :– Edit Theme page will be opened, click on the header.php add below line.
<?php echo do_shortcode('[bis_country_selector]'); ?>
Below are different option available with country dropdown.
[bis_country_selector]: Default usage to generate country drop down.
[bis_country_selector include="IN,US" ]: Generate country drop down with only India and US countries.
[bis_country_selector exclude="IN, US" ]: Generate country drop down excluding only India and US countries.
[bis_country_selector exclude="IN,US" eng_label="true" ]: Generate country drop down excluding only India and US countries and drop down with English labels. eng_label can have true, false and only option and default value is false.
[bis_country_selector exclude="IN,US" class=”custom-css” ]: Generate country dropdown excluding only India and US countries with custom dropdown class.
Creating Redirect Rule
Click on Redirect Rules from left menu or from Dashboard. Redirect Rules list page will be displayed as shown below. Click on + Add Rule button, New Redirect Rule Page will be displayed.
Provide appropriate values for below fields.
Rule Name : Redirect Rule name and should be unique.
ex. India Amazon Site Redirect
Description : Appropriate description for your rule.
Redirect Type : 301 or 302.
Status : This feature is useful if you would like to deactivate or activate rule.
Target URL : URL to which you want to redirect
ex : In our sample use case it is https://www.amazon.in/
Add Rule : Used to define on what condition/criteria we want to direct. In our sample, we would like to redirect for India website on changing the dropdown.
So the rule is defined using Request Criteria and with Form Data as Sub category and value should be bis_country=IN (Where IN is ISO country code of India).
Similarly if you would like to define for France value will be bis_country=FR and for United States value will be bis_country=US.
These are universal standard ISO country codes. Click here for country codes
To persist the user select country update the rule with cookie value as shown in the below screen. For all new requests user selected country will be used and user will be redirected country specific website.
This is how we can define redirection rules, if you need more info send mail to email@example.com we can provide more samples.