Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Anyone know how to validate a zip code?


phi148

Recommended Posts

Customers who mistakenly type in incorrect zip codes is screwing up my shipping module.

 

Anybody know a way to validate that a zip code is VALID prior to letting a customer create an account or change shipping/billing address?

 

I don't even care at this point about matching it to a city / state.  That would be a bonus.

 

I just want to stop invalid zip's by somebody with a fat finger.

 

Thanks!

Link to comment
Share on other sites

  • Replies 51
  • Created
  • Last Reply

you may want to specify your shipper as all of them do have a address validation module. also, what shipping software do you use as software like endicia (worldship/shipmanager and etc.) would warns if the shipping address doesn't match the system...if you can code, go with the address validation moduloue, and if you can't, i say go with a good shipping software to catch bad addresses...i had written the address validation module for fedexwsdl and you can have it if you use fedex for shipping...

Link to comment
Share on other sites

First, I got this idea from Burt.  i added the Google "Place Autocomplete Address Form" to my creat account page fairly easily and it works pretty well.  I'm in the US and only deal with US shipments though.  You can see the Google code example and learn about it at the link below. 

https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform

 

It fills in the whole address when they select it.  I've only been using it a few weeks but haven't had any errors since. I didn't have to change any of my address fields either, just add the autocomplete line.

I'm not really a dog.

Link to comment
Share on other sites

you may want to specify your shipper as all of them do have a address validation module. also, what shipping software do you use as software like endicia (worldship/shipmanager and etc.) would warns if the shipping address doesn't match the system...if you can code, go with the address validation moduloue, and if you can't, i say go with a good shipping software to catch bad addresses...i had written the address validation module for fedexwsdl and you can have it if you use fedex for shipping...

 

I am using the freightquote.com module.   The freightquote module handles the error just fine, however, when it passes back the error code to checkout_shipping.php ... that page just hangs.  

 

It seems as if the standard infrastructure of oscommerce is not sure how to handle the error.

Link to comment
Share on other sites

First, I got this idea from Burt.  i added the Google "Place Autocomplete Address Form" to my creat account page fairly easily and it works pretty well.  I'm in the US and only deal with US shipments though.  You can see the Google code example and learn about it at the link below. 

https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform

 

It fills in the whole address when they select it.  I've only been using it a few weeks but haven't had any errors since. I didn't have to change any of my address fields either, just add the autocomplete line.

 

This is pretty interesting!  I'll be taking a look at this and I'll let you know how it goes.  Thanks for the tip!!  :)

Link to comment
Share on other sites

  • 1 month later...

John W

 

  What did you mean by "add the autocomplete line"?  I have gotten the API working but the autocomplete does not work and have to iron out the "required fields" stuff......but am getting closer...

Link to comment
Share on other sites

I understand now what you meant.......but what I found was that when a new account is being created, one of the required input fields is "street address".  Now the Google API marks a "address" and a "route".....of course there is no way to combine two "id's" in one input, and I realized it was going to be more than I wanted to try at the time with everything else going on.

 

I got it working on the create account page in my store, and when I started typing my address it only included the street number in the "street address" field......not the name of the street itself.....that was placed in a different field altogether.....

 

Darn good idea though......

Link to comment
Share on other sites

yours worked perfect......but could not get it on mine.....more grind I guess   :)

 

this was my issue......say my address is 123 somewhere lane....

 

the app from google separated it by "street number" and "route".......so when I placed it on  my account page for the street address field I would only get "123"......."somewhere lane" would not be included......

 

thoughts about that?

Link to comment
Share on other sites

I didn't change anything on my fields.  I just put the section for the autocomplete and added the javascript with a conditional statement to only work on create account.  If you like, put a link and I'll look at yours.

 

Burt is close to module that can simply be turned on from Admin that needs no modification. 

I'm not really a dog.

Link to comment
Share on other sites

I have been using this on my live site for a few months but I have a couple of addresses that are missing the street number.  It may be better to have the street number separate like Google does on their example.

I'm not really a dog.

Link to comment
Share on other sites

Ok......this is driving me nuts......it cannot be this hard......this is the first section of the code for my create_account.php file where the street address is entered......please compare to yours and see what the difference is......I know I have got to be missing something small....

      <tr>
        <td class="fieldKey"><?php echo ENTRY_STREET_ADDRESS; ?></td>
        <td class="fieldValue"><?php echo tep_draw_input_field('street_address') . ' ' . (tep_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_STREET_ADDRESS_TEXT . '</span>': ''); ?></td>
      </tr>

I have the div statement above the this and am able to type in my address and the drop down does work as it should......but when I select it, it does not input the address into the fields that it should.

 

thanks...

Link to comment
Share on other sites

Here's my section below including Google address complete.  But your code looks older and not 2.3.4 BS version. That might be your problem.  I upgraded all my catalog pages that display html.  Are you using utf-8? 


  <div class="alert alert-info"><i class="fa fa-info-circle"></i> Quick and Easy Address Lookup, this will autocomplete your address.</div>
  <div class="form-group">
    <label for="autocomplete" class="control-label col-sm-3"><img src="images/icons/powered_by_google_on_white.png" alt="powered by Google"/></label>
    <div class="col-sm-9" id="locationField">
      <input type="text" name="autocomplete" id="autocomplete" onFocus="geolocate()" placeholder="Start Typing Your Address - this will autofill in the match you select" class="form-control" />
    </div>
  </div>
  <hr>

  <div class="contentText">
    <div class="form-group has-feedback">
      <label for="inputStreet" class="control-label col-sm-3"><?php echo ENTRY_STREET_ADDRESS; ?></label>
      <div class="col-sm-9">
        <?php
        echo tep_draw_input_field('street_address', NULL, 'required aria-required="true" id="inputStreet" placeholder="' . ENTRY_STREET_ADDRESS . '"');
        echo FORM_REQUIRED_INPUT;
        if (tep_not_null(ENTRY_STREET_ADDRESS_TEXT)) echo '<span class="help-block">' . ENTRY_STREET_ADDRESS_TEXT . '</span>';
        ?>
      </div>
    </div>

I'm not really a dog.

Link to comment
Share on other sites

I am using ver 2.3.1......that may be the problem

 

I tried to incorporate some of your coding within mine and it said NO......lol

 

Am going to try to tinker with it some more and see what I can come up with......

 

thanks though........yours works awesome.....

Link to comment
Share on other sites

Sorry, I thought you were using the current BS version.  Look at updating to the BS version and eventually you probably will anyway.  If you are good with a file comparator like Beyond Compare then you can start upgrading pretty easily IMHO.  I only did the BS on my catalog pages that display html.  The responsive design is really where you want to go with this long term. 

 

Beyond my catalog pages I updated pages involving session, database, and went through to correct any addons that caused problems.  I'm running php 5.6 since Thanksgiving.

I'm not really a dog.

Link to comment
Share on other sites

I don't know if it's going to work with that version.  Start looking at the Bootstrap version and you can make prorgress quickly interegrating it.  Especially if you are full 2.3.1. depending on how much you've modified it. 

I'm not really a dog.

Link to comment
Share on other sites

I installed the Bootstrap version on a separate server to see the layout and all that.......now the store that I am working on is "not live yet" is from a template and I have no clue how to integrate my store template into the layout of BS version......looked completely different.....

 

I have placed this project on the back burner for a while.....I know that it is a handy lil thing to have and there really should not be that much to it......but I have not got the functionality of it to work using the way the code is for 2.3.1

 

bummer I know.....

Link to comment
Share on other sites

  • 2 months later...

i would be very interested if anyone has succeded on this on 2.3.4 BS... Have a shop where its much needed 

 

ideal if the autocomplete also worked in admin so i can edit acounts and correct people's adresses from there

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...