1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Change default country selected in shipping / billing address?

Change default country selected in shipping / billing address?

5 posts, 0 answered
  1. Ryan
    Ryan avatar
    17 posts
    Registered:
    18 Jun 2012
    20 Jun 2012
    Link to this post
    Currently, the default country selected for the checkout widget in address information is Algeria.  How can I change that?
  2. Randy Hodge
    Randy Hodge avatar
    96 posts
    Registered:
    03 Nov 2014
    22 Jun 2012
    Link to this post
    Hello, Ryan.

    Thank you for contacting us.

    The Checkout widget is a complex. largely self-contained control that currently does not have the level of configurability required to change which country is displayed in that dropdown. You would have to create your own checkout widget. If that interests you, please take a look at this blog post which discusses custom checkout and has source code.

    I apologize for any inconvenience. Please let us know if you have any further questions.

    All the best,
    Randy Hodge
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Ryan
    Ryan avatar
    17 posts
    Registered:
    18 Jun 2012
    22 Jun 2012
    Link to this post
    Is there a way to change it using javascript (i.e. during a onload event)?
  4. Stephen2
    Stephen2 avatar
    94 posts
    Registered:
    05 Feb 2012
    03 Nov 2012
    Link to this post
    Anyone still interested in this here was my solution, adapted from Telerik's internal JS that gets called.

    Add this to the bottom of your Shipping/billing address form template:
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function pageLoad() {
              var countryShipping = $find($(".sfCountryShipping").attr("id"));
              var countryBilling = $find($(".sfCountryBilling").attr("id"));         
              countryShipping ? countryShipping.findItemByValue('AU').select() : 0;
              countryBilling ? countryBilling.findItemByValue('AU').select() : 0;
            }
         </script>
    </telerik:RadCodeBlock>

    The ternary :0 is required, because this code actually gets run through twice on page load for some reason, the 1st time $find will return 'null'...
  5. Stephen2
    Stephen2 avatar
    94 posts
    Registered:
    05 Feb 2012
    03 Nov 2012
    Link to this post
    Just had a thought & caveat.  This setup is for a shop that doesn't allow sign in, and therefore the country/state fields are not pre-populated...

    Not sure how this will interfere with pre-populated fields, please bear in mind.
5 posts, 0 answered