EDIT - REVISED 12/8/2018 - Fixed issue to allow for stores with alternate ship to address to be verified.
Instructions have been totally revised below to work with checkout regardless if you use allow a secondary ship to address for customers.
I was asked for help implementing smartystreets on a .php site, I previously worked this out for .asp and the install is just about the same for both versions.
Details below.
There are a number of settings on your store that may impact how this operates, so keep that in mind and if you need help, ask questions in this thread and I will see if I can help.
For some time now, we have been using smartystreets on my busy ect store. It has been a powerful tool for getting valid addresses from customers.
This helps cut down on shipping errors and address correction fees from UPS and fedex.
This will also help mobile users populate the address fields faster.
NOTE - Some browsers will try to populate the address and there does not seem to be much we can do to force the smartystreet usage from the customers, but I can tell you more than 90% of our orders come through with validated addresses.
This is implemented in your cart.php or cart.asp pages and that means it will
not get overwritten by updates to your ect store.
smarty streets - https://smartystreets.com/
here is a page with details of how it works. They have a ton of code examples and great info on customizations.
https://smartystreets.com/products/plugins/jquery
You can start with the website plugin - 250 lookups for free every month to test with. If you have a busy store, you may need a paid package. (I have 60,000 lookups a year plan)
documentation and link to setup a free testing account
https://smartystreets.com/docs/plugins/website
===STEP ONE===The first thing you need is open your cart.php or cart.asp page in your html editor and see if you already have the jquery plugin.
Use "find" to search the page code for the word jquery.
If you do not have it, add this to the <head> section of the page
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
===STEP TWO===Below, in the content area of the page, after the cart include line ( <?php include "vsadmin/inc/inccart.php" ?> or <!--#include file="vsadmin/inc/inccart.asp"--> )
add the following...
.ASP VERSION<% if SESSION("country")="" then SESSION("country")="United States of America" %>
.PHP VERSION<?php if (!isset($_SESSION['country'])) { $_SESSION['country']='United States of America'; } ?>
NOTE - you may need to change United States of America to USA depending on how its listed in your drop down===STEP THREE===The last step is the javascript to make it work. For your convenience, it's the same for both .asp and .php versions.
Add this below the code you added in step two
NOTE - Be sure to insert your key in place of YOUR_WEBSITE_KEY_HERE
<script src="//d79i1fxsrar4t.cloudfront.net/jquery.liveaddress/5.1/jquery.liveaddress.min.js"></script>
<script>
window.onload = onPageLoad();
$("#shipdiff").click(function() {
verifychange(this)
});
function onPageLoad() {
if($("#shipdiff").prop('checked') == false)
verifychange('#shipdiff');
}
function verifychange(obj) {
if($(obj).is(":checked")){
document.getElementById("scountry").value = 1;
checkoutspan('s');
var ss = jQuery.LiveAddress({
key: 'YOUR_WEBSITE_KEY_HERE',
verifySecondary: true,
debug: false,
autocomplete: 7,
submitVerify: false,
target: "US",
addresses: [{
address1: "#address",
address2: "#address2",
locality: "#city",
administrative_area: "#state",
postal_code: "#zip",
country: "#country"
}, {
address1: "#saddress",
address2: "#saddress2",
locality: "#scity",
administrative_area: "#sstate",
postal_code: "#szip"
}]
});
}else{
var ss = jQuery.LiveAddress({
key: 'YOUR_WEBSITE_KEY_HERE',
verifySecondary: true,
debug: false,
autocomplete: 7,
submitVerify: false,
target: "US",
addresses: [{
address1: "#address",
address2: "#address2",
locality: "#city",
administrative_area: "#state",
postal_code: "#zip",
country: "#country"
}]
});
} }
</script>
There is a list of options here - https://smartystreets.com/docs/plugins/website/configure
for example, I have autocomplete set to 7 there and verify secondary is set to true so if a suite number is missing, the customer will be prompted for it.
Those options should be listed with a comma there.
To get your key, register and create a website key here - https://smartystreets.com/account#keys
Upload the page and it should be working on your cart page.
You can see a demo on my php test site here by adding that item to cart and proceed to checkout step 2 (address entry).
http://www.floridasurpluswarehouse.com/dev/proddetail.php?prod=scanner001
Enjoy,
David