The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

state field on checkout page autofilled with "South Carolina" for an Australia only store

sunsurfsunsurf Member
in Help edited July 2011
Hello Team Foxycart,

My client is loving foxycart. The system is working really well for their home delivery business in Australia. They are subscribed for 2 different domains (both are on 0.7.1) and the orders are flying in.

The client only delivers in Adelaide, which is in the state of South Australia.

Unfortunately a few of their customers have had issues with the state field for some reason - with "South Carolina" (definitely not a state in Australia) being autofilled in the state field as soon as they type an 'S'.

This is weird as all these customers are based in South Australia.

Unfortunately I am unable to replicate the error this end - I always get South Australia and it works perfectly for me.

I have some details from the client about 2 such customer orders

Date: order from 29 June at 9.15 am
Device: PC
OS: Windows
Browser: IE
Internet Service Provider: "Engine"
Login or as Guest: Logging in to Foxycart

Date: order from 23 June at 10.33 pm
Device: MacBook Pro
OS: Mac OSX 10.6.7
Browser: Safari
Internet Service Provider: "Internode" ISP
Login or as Guest: Logging in to Foxycart

I don't think it has anything to do with the ISP as I use the same ISP and have no problems.

It has happened to about 10 or so different customers so far - some while placing an order from their iphone.

Have you seen this before?

Any ideas?
Comments
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    I think what might be going on is that for whatever reason some users aren't getting tagged as Australia (but the US instead) and they can't fix it because the country field is hidden. Try this to make doubly sure that Australia is what is getting set:
    <script type="text/javascript">
    jQuery(document).ready(function($){
    	$("#customer_country_name").val("Australia");
    	FC.checkout.validateLocationName("customer_country_name");
    });
    </script>
    

    Not tested, but it might solve the problem for you.

    Absolutely beautiful site and a very creative checkout design. I love it...
  • lukeluke FoxyCart Team
    Hey sunsurf. It's possible the Country is being seen as the US (it's based off of GeoIP) which would pre-fill the state fields with US states. If you're hiding the country field, there'd be no way for the customer to know what was going on. You may need some JavaScript on your checkout template to pre-fill it and then call FC.checkout.validateLocationName to update the states/provinces. This might be helpful as well: http://wiki.foxycart.com/snippets/shipping/restricting_countries_from_the_checkout_form#some_code_for_serving_the_us_only
  • Hello Sparkweb,

    Thanks so much for the wonderful feedback on the site and the great suggestion.

    I have unhid the country field and added your code to the checkout page - that certainly populates Australia into the country field - hopefully that does the trick.

    Many thanks!
  • Hi Luke,

    Ah I see - that makes sense then for the wrong state. Thanks for working that out.

    How do I get it to make sure Australian state options come up (eg type s and South Australia comes up)? I am trying the FC.checkout validation below but it breaks the code - I must not be calling it quite right in between the jquery doc ready call...
    $('#customer_country').val('AU'); 
    $('#customer_country_name').addClass('fc_text_readonly').val('Australia'); 
    $('#customer_country_name').attr('readonly', true).focus(function() { 
    $(this).blur(); 
    }); 
    FC.checkout.validateLocationName("customer_country_name");
    

    Any ideas?

    Thanks for your help.
  • This seems to do it....

    $('#customer_country').val('AU');
    $('#customer_country_name').addClass('fc_text_readonly').val('Australia');
    $('#customer_country_name').attr('readonly', true).focus(function() {
    $(this).blur();
    FC.checkout.validateLocationName("customer_country_name");
    });

    Thanks for your help Luke and sparkweb.
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    Just one more thing to add... as long as the customer country field is set to Australia you don't have to have it showing. It can be hidden.... it's the validateLocationName function which sets the states as prefills based on what the country is.
  • fc_adamfc_adam FoxyCart Team
    If I could quickly add a consideration here - it might actually make more sense to not hide the country field. Considering its read-only by using that script, users can't change it. But consider a user making it to the checkout who live in a different country and completely missed the fact your only local to SA. Showing that only Australia is selectable is a pretty clear indicator that they can't check out from where they live. Not a necessity, but possibly something to keep in mind in terms of ease of use.
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    @fc_adam, that makes sense and is a good idea. Recently I built one of these that was only US and realized that it was probably frustrating for the user to try to click on the US field and not get a focus or alert or anything. So you could do something like this:
    $('#customer_country_name')
    	.val('Australia')
    	.attr('readonly', true)
    	.dblclick(function() {
    		alert("Shipping is only available to Australia.");
    	});
    

    This would give them an alert when, in frustration, they double click on the field name.
  • sunsurfsunsurf Member
    edited July 2011
    Thanks so much sparkweb and fc_adam - this just keeps getting better!

    Based on your suggestions the client is happy for the country field to be visible to aid userbility and for your scripting to do its magic.

    I love that double click alert.

    Many thanks.
  • sunsurfsunsurf Member
    edited February 2012
    Hello again Team Foxycart,

    The South Carolina issue is popping up again for one of my client's customers (its the same customer that reported it last time).

    To confirm, it is an for Australian shop, and South Australia should be the only "South" option.

    We have been using the awesome code above to pre-fill Australia into the Country field on the checkout page:
    $('#customer_country').val('AU');
      $('#customer_country_name').addClass('fc_text_readonly').val('Australia');
      $('#customer_country_name').attr('readonly', true).dblclick(function() {
       alert("Delivery is only available to selected postcodes in Adelaide, Australia");
    	FC.checkout.validateLocationName("customer_country_name");
      });
    

    The customer sent a screen cap and "United States" is actually pre-filled somehow in the Country field on their checkout page, in spite of using the "Australia pre-fill" code above.

    I am unable to replicate the error this end even though I have tested with the same browser (Safari), on one of the same computers (Apple MacBook Pro), and with the same internet provider (internode). Her operating software is is Mac OS X 10.6.7. The customer logged in and created a password.

    I am stumped as to how South Carolina could pop up when JS is being used to pre-fill Australia - and how United States could be pre-filled on her machine.

    Any ideas?
  • fc_adamfc_adam FoxyCart Team
    @sunsurf,

    Was it by chance the shipping field rather than the billing field?
  • Hi Adam,

    Good question. Looking at the screen cap it says "Delivery Address" so I would presume it is the Billing field.

    (The Billing Address was renamed to Delivery Address in the language / cart customisation during the setup)

    To simplify the checkout page, we don't show the shipping fields on the checkout page.

    Any ideas?
  • fc_adamfc_adam FoxyCart Team
    Try adding this
    FC.checkout.setAutoComplete("customer_country");
    FC.checkout.setAutoComplete("customer_state");
    

    instead of this:
    FC.checkout.validateLocationName("customer_country_name");
    
  • sunsurfsunsurf Member
    edited February 2012
    Thanks Adam,

    I have plugged in that new code and it looks fine (as expected) my end.

    I am just waiting to hear from the customer...
Sign In or Register to comment.