Docs Country Based Restrictions for WooCommerce How to Use the Country Detection Shortcode

How to Use the Country Detection Shortcode

You can use the following shortcodes to display country detection widgets in your store and enhance the customer experience.

1. [cbr_location_widget] Shortcode

This shortcode displays a country detection widget that informs customers about the detected country.

Usage:
Place the shortcode anywhere on your store to display the widget.

[cbr_location_widget]

Optional Parameters:

  • Title: Adds a custom label before the detected country name. Example: label=”Shipping to “
  • Show Icon: Displays a map icon next to the country name. Use icon=show to enable this feature.
  • Show Border: Adds a border around the widget. Use border=show to enable this feature.
  • Country Type: Defines which country type to display. selling – Displays the selling country OR shipping – Displays the shipping country.

Example Usage:

[cbr_location_widget label="Shipping to " icon=show border=show country_type=selling]

Usage in the Theme Header:

To include the widget in your theme header, add the following code to your header.php file:

<?php echo do_shortcode('[cbr_location_widget label="Shipping to " icon=show border=show country_type=selling]'); ?>

2. [cbr_select_countries_widget] Shortcode

This shortcode displays a dropdown where customers can manually select a country for detection.

Usage:
Place the shortcode anywhere on your store to show the country selection dropdown.

[cbr_select_countries_widget]

Optional Parameters:

  • Refresh: Determines whether the page should refresh after the country is changed.
    • 1 – Refresh after country change.
    • 0 – Do not refresh.

Example Usage:

[cbr_select_countries_widget refresh=1]

By using these shortcodes, you can easily provide a seamless country detection and selection experience for your customers.