1. Home
  2. Knowledge Base
  3. WooCommerce Wholesale Lead Capture
  4. Styling
  5. How To Set A Default Country On Registration Form
  1. Home
  2. Knowledge Base
  3. WooCommerce Wholesale Lead Capture
  4. How To Set A Default Country On Registration Form

How To Set A Default Country On Registration Form

If you typically accept most of your wholesale registrations from one country you might like to default the country to a specific one.

To do this currently in WooCommerce Wholesale Lead Capture you need to add a small snippet of code to your functions.php file in your theme:

// Change the default country on WooCommerce Wholesale Lead Capture's registration
function wwsSetRegistrationDefaultCountry() {
    if ( is_page( 'wholesale-registration-page' ) ) {
		?>
        <script type="text/javascript">
            jQuery(document).ready(function () {
                jQuery('select#wwlc_country').val('AU');
                jQuery('select#wwlc_country').trigger('change');
            });
        </script>
        <?php
    }
}
add_action( 'wp_footer', 'wwsSetRegistrationDefaultCountry', 99 );

A few notes on implementing this code:test

  1. If you have renamed the registration page, it’s possible that the page slug has changed as well. Ensure you replace ‘wholesale-registration-page’ in the code above with the correct page slug
  2. The code above will default to ‘AU’ which is Australia. Change this to whichever country you want to default to. You can find a list of 2-digit country codes here.

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support