Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2015
    Posts
    244
    Plugin Contributions
    0

    Default Autofill City & State from Zip Code

    does anyone know if there is a plugin or module that can help me Autofill City & State from Zip Code .

    Baiscally when a customer puts his zip code i want the city and state to auto populate.

    If someone could assist me or lead me in the right direction i would appreciate it

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    9,311
    Plugin Contributions
    72

    Default Re: Autofill City & State from Zip Code

    Quote Originally Posted by chadlly2003 View Post
    does anyone know if there is a plugin or module that can help me Autofill City & State from Zip Code .

    Baiscally when a customer puts his zip code i want the city and state to auto populate.

    If someone could assist me or lead me in the right direction i would appreciate it
    I've been using this Zip Codes to Location service (https://www.zipcodeapi.com/index.php) for a couple of years now; works the treat!

  3. #3
    Join Date
    Jan 2015
    Posts
    244
    Plugin Contributions
    0

    Default Re: Autofill City & State from Zip Code

    Lat9,

    Do you have an example of implementation. I am not really sure how to go about getting this to work with zencart

  4. #4
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    1,431
    Plugin Contributions
    2

    Default Re: Autofill City & State from Zip Code

    interesting API... like it... i think...

    does not seem that tricky to implement, with the exception of the "...has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."

    is.gd/fNujQC

    i think it totally makes sense to enter zip codes first and then autofill city state codes...

    securely addressing the above error will be the tricky part...

    @chadlly2003, the way to implement this is to register for an application key, copy the the javascript code from here:

    https://www.zipcodeapi.com/API#example1

    and then place that on the page where you have your address... you then need to change the key in the js code to your key, find this code:

    Code:
    //from:
    container.find("input[name='zipcode']").on("keyup change", function() {
    //to:
    container.find("input[name='postcode']").on("keyup change", function() {
    you will then need to find the container that the postcode is in on your page, and change the following 2 elements:

    Code:
    		var container = $("#example1");
    		var errorDiv = container.find("div.text-error");
    is.gd/fNujQC


    those 2 elements will be dependent on your template.

    hope that gives you enough to go on.... not super easy but again not super hard. the error i'm experiencing above will be tickier to solve. you should be able to see that in the developer tools console of your browser.

    good luck.
    no good deed goes unpunished. help out with the green....

  5. #5
    Join Date
    Jan 2015
    Posts
    244
    Plugin Contributions
    0

    Default Re: Autofill City & State from Zip Code

    Actually I figured it out. Was a lot easier than I thought. Working perfectly on my site:)

 

 

Similar Threads

  1. v153 Restrict Store Pickup to City or Zip Code Radius?
    By fabburl in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 28 Jun 2015, 11:52 PM
  2. getting rid of City and Zip Code
    By eatmyswan in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 13 May 2006, 09:29 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR