Create a custom country/currency switcher template via a theme

If you are a developer (or you have PHP knowledge), you can customize the templates included in Price Based on Country in an upgrade-safe way using overrides.

To create a custom template, you have to copy the template into a directory within your theme named woocommerce-product-price-based-on-countries

Example: To override the country switcher template, copy: wp-content/plugins/woocommerce-product-price-based-on-countries/templates/country-selector.php to wp-content/themes/yourtheme/woocommerce-product-price-based-on-countries/country-selector.php

After copying the file, you can edit it to suit your style requirements.

Override the templates via theme ensures that any changes you make will not be erased when you update Price Based on Country.

Note: Use a child-theme guarantee that you will not lose your changes when updating your parent theme.

Create a custom country switcher

The country switcher template is part of the Basic version.  To override this template, copy the file

wp-content/plugins/woocommerce-product-price-based-on-countries/templates/country-selector.php

Country switcher template location

To:

wp-content/themes/yourtheme/woocommerce-product-price-based-on-countries/country-selector.php

Override country switcher template via theme

Open the file and make any changes you need.

Variables available in the country switcher template:

  • $countries — A key-value pair array that contains the list of countries in the format: country code > country name
  • $selected_country — The current country code selected.

Create a custom currency switcher

Pro version featureUpgrade to Pro now!

The country switcher template is part of the Pro-addon. To override this template copy the file

wp-content/plugins/woocommerce-price-based-country-pro-addon/templates/currency-switcher.php

Currency switcher file location

To:

wp-content/themes/yourtheme/woocommerce-product-price-based-on-countries/currency-switcher.php

Override currency switcher template via theme

Open the file and make any changes you need.

Variables available in the currency switcher template:

  • $options — A key-value pair array in the format: country code > currency text.
  • $selected_country — The current country code selected.

See also