Country specific messages on checkout

CliffSCliffS Member
in Help edited May 2014
We ship many packages to different countries, and we need to warn some customers about slow service, and ask other customers for additional details.

For example, we wish to tell our Russian customers that delivery times will be 30 to 90 days.
We wish to ask our customers from Korea to give their address using both English and Han-geul fonts.
Ideally, these messages will be in the native language for each country.

How do we go about doing this?
Comments
  • fc_adamfc_adam FoxyCart Team
    @CliffS,

    You would do this with javascript on your checkout page - and detect changes to the country fields and display different alerts/content on the page accordingly. To detect changes, you'd simply attach a jQuery change event to the two country fields and perform actions there depending on it's value.
  • CliffSCliffS Member
    Uh, thank you. I think. I especially appreciate the phrase, "... simply attach a jQuery change event ..."

    Umm, there may be a few of us for whom this may not be simple. Could you give an example?
  • fc_adamfc_adam FoxyCart Team
    @CliffS,

    Sorry about that - sure thing. Including this on your checkout should help get you started:
    <script type="text/javascript">
    jQuery(document).ready(function() {
      jQuery("#customer_country, #shipping_country").change(function() {
        updateMessage();
      });
    
      updateMessage();
    });
    
    function updateMessage() {
      var country = (jQuery("#use_different_addresses").is(":checked") ? $("#shipping_country").val() : $("#customer_country").val());
      var message = "";
    
      if (country == "US") {
        message = "This is a message for US based customers";
      } else if (country == "CA") {
        message = "A message just for Canadian customers";
      } else if (country == "KR") {
        message = "South Korean customers would see this message";
      }
    
      jQuery("#messageHolder").html(message);
    }
    </script>
    


    Then in your checkout template, you need to include the markup where this message will be displayed - which could be anywhere. Just give the element that contains the message text an id of "messageHolder" - which could look like this:
    <div>
      <p id="messageHolder"></p>
    </div>
    
  • CliffSCliffS Member
    Big thanks, Adam!

    Really appreciate the over-the-top help!

    Best wishes,
    -Cliff
  • CliffSCliffS Member
    Works like a charm. You're terrific, Adam!
  • fc_adamfc_adam FoxyCart Team
    @CliffS - awesome!
Sign In or Register to comment.