magga Posted December 11, 2008 Share Posted December 11, 2008 (edited) Hi everyone, I have recently implemented an autofill address from postcode script into my site so I'd like to share this for other UK users to take advantage of! You can see a demo here, however please note that it is in demo mode only at the moment so only the postcode ZZ99 or a Nottingham postcode e.g. NG1 1GA will work: https://www.magdesign.co.uk/clients/register.php You can also see it on the cart page: https://www.magdesign.co.uk/clients/cart.php?a=checkout You do have to buy credits to use the address autofill as the lookups are done from a big database of addresses held elsewhere. As I can't place adverts for other sites on here, if anyone wants a 10% promotional discount code for their first order of postcode credits and details of where to purchase them from, please PM me. I have attached 3 files that are needed for this lookup to work, you can upload these to anwhere you like, just make sure they are all in the same folder and you put the correct path to them in the template files. Firstly, you need to edit your header.tpl file: Add this line within your <head></head> tags: <script type="text/javascript" src="/SPL_AJAX_Full.js"></script> The path above must reference where the SPL_AJAX_Full.js script is. Next edit your clientregister.tpl file: Find the line: <tr><td class="fieldarea">{$LANG.clientarealastname}</td><td><input type="text" name="lastname" size=30 value="{$clientlastname}"> *</td></tr> And move the table row that includes the postcode field to be below it, and add an id="postcode" to the text input: <tr><td class="fieldarea">{$LANG.clientarealastname}</td><td><input type="text" name="lastname" size=30 value="{$clientlastname}"> *</td></tr> <tr><td class="fieldarea">{$LANG.clientareapostcode}</td><td><input type="text" name="postcode" [b]id="postcode"[/b] size=10 value="{$clientpostcode}"> *</td></tr> Next, you must add a button next to this field that will call the address lookup script: <tr><td class="fieldarea">{$LANG.clientareapostcode}</td><td><input type="text" name="postcode" id="postcode"size=10 value="{$clientpostcode}"> * [b]<input type="button" onclick="Javascript:SPLGetAddressData(document.getElementById('postcode').value); javascript: document.getElementById('addresslist').style.display='';" value="Find Address">[/b]</td></tr> Next you should add a table row below the postcode row, this will be where the addresses are then listed, the style="display: none" makes it only appear when the lookup button is clicked: <tr id="addresslist" style="display: none"><td class="fieldarea"></td><td><div id="SPLSearchArea" /></div></td></tr> Make sure the field id's referenced in the script are the same as the ones in your template. Towards the bottom of the SPL_AJAX_Full.js file, you will see a load of fields: document.getElementById("company").value=COMP; document.getElementById("postcode").value=POSTCODE; document.getElementById("line1").value=LINE1; document.getElementById("line2").value=LINE2; document.getElementById("town").value=TOWN; document.getElementById("county").value=COUNTY; document.getElementById("country").value=COUNTRY The bracketed values refer to id of the field (in your template) where you want that particular part of the address to be inserted. If you used the above values, then your Company text field in your template MUST have an id of "company", your Address 1 must have an id of "line1" and so on, much like below: <input type="text" name="companyname" [b]id="company"[/b] size=30 value="{$clientcompanyname}"> <input type="text" name="address1" [b]id="line1"[/b] size=40 value="{$clientaddress1}"> You then need to add the CSS into your stylesheet: <STYLE type="text/css"> .SPLAddressListSt{ font-family: Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0; margin-bottom: 0; width: 80mm;} .SPLAddressListStBottomLine{ font-family: Arial, Helvetica, sans-serif; font-size: 10px; text-align: center; margin-top: 0; margin-bottom: 0; } .SPLAddressListStErrorLine{ font-family: Arial, Helvetica, sans-serif; font-size: 14px; text-align: center; margin-top: 0; margin-bottom: 0; } .SPLAddressListLicenseLine{ font-family: Arial, Helvetica, sans-serif; font-size: 10px; text-align: center margin-top: 0; margin-bottom: 0; } </STYLE> SPLAddressListSt is the style of the address selection box SPLAddressListStBottomLine is the style of the line below selection box SPLAddressListStErrorLine is the style of text which appears if Postcode is not found SPLAddressListLicenseLine is the style for the License information When you sign up for the credits, you will be given a "Data Key" which you must enter at the top of the 2 attached .php files. You can use all this code in the exact same way on your viewcart.tpl page too as clients can also register on this page. Hope this is useful for you all, any questions, please ask me! AJAX PHP Full Address.zip Edited December 11, 2008 by magga 0 Quote Link to comment Share on other sites More sharing options...
LemonBarley Posted December 11, 2008 Share Posted December 11, 2008 wow. this is a nice script. but what about other countries? like Singapore? 0 Quote Link to comment Share on other sites More sharing options...
magga Posted December 11, 2008 Author Share Posted December 11, 2008 Hi there, I'm afraid this version will only work for UK addresses 0 Quote Link to comment Share on other sites More sharing options...
openmind Posted December 11, 2008 Share Posted December 11, 2008 Looks like a great idea but when I tried your register page it didn't find my or other postcodes I entered which I know are valid. In addition, if it doesn't find the postcode first time and you change the value to check, the submit button doesn't appear to checking the new value. You have to refresh the page to get the script firing again. Looks like a great add-on though if you can iron out these issues and I would definitely be interested 0 Quote Link to comment Share on other sites More sharing options...
Daniel Posted December 11, 2008 Share Posted December 11, 2008 As explained in the first post Phil, it's in demo mode - Had me confused for a while too 0 Quote Link to comment Share on other sites More sharing options...
openmind Posted December 11, 2008 Share Posted December 11, 2008 As explained in the first post Phil, it's in demo mode - Had me confused for a while too That will teach me to skim read PM sent... 0 Quote Link to comment Share on other sites More sharing options...
chickendippers Posted December 11, 2008 Share Posted December 11, 2008 Very nice! However to be practical it would also need provision for international addresses. P.S. Wicked WHMCS customisation. 0 Quote Link to comment Share on other sites More sharing options...
magga Posted December 11, 2008 Author Share Posted December 11, 2008 Hi chickendippers, First of all thanks! Secondly, I'm not sure which other countries have an address database that can be accessed however I will have a look into this. 0 Quote Link to comment Share on other sites More sharing options...
chickendippers Posted December 11, 2008 Share Posted December 11, 2008 How about having the full address fields available so that non-UK customers can just type their address in as normal? 0 Quote Link to comment Share on other sites More sharing options...
magga Posted December 11, 2008 Author Share Posted December 11, 2008 The address fields can still be typed in as normal anyway, I could possibly add something that disables the Find Address button if United Kingdom is not selected in the drop down menu. 0 Quote Link to comment Share on other sites More sharing options...
xperience Posted December 12, 2008 Share Posted December 12, 2008 We use http://www.postcodeanywhere.co.uk - a much better system from what I can see. One simple line of code needed and provides worldwide postcodes as well as UK. Not sure how it compares on price. 0 Quote Link to comment Share on other sites More sharing options...
magga Posted December 12, 2008 Author Share Posted December 12, 2008 Yes I'm aware of Postcode Anywhere, seems like it's harder to integrate however and also the credits are slighty more expensive on your first order, £250 for 6,000 with them or £210 (+ 10% off your first order with promo code) for 5,000 with Simply Postcode. This thread is aimed at UK users initially, hence why it's stated in the title. 0 Quote Link to comment Share on other sites More sharing options...
xperience Posted December 12, 2008 Share Posted December 12, 2008 Yes I'm aware of Postcode Anywhere, seems like it's harder to integrate however and also the credits are slighty more expensive on your first order, £250 for 6,000 with them or £210 (+ 10% off your first order with promo code) for 5,000 with Simply Postcode. I disagree about intergration -it's an absolute doddle! One line of code next to the post code field on your form - then the software does the rest. All credits are time limited so buying 5000 if you're not going to use them is surely false economy (unless you're really doing 30 lookups a day!) We pay about £100 a year for the credits we need. (plus neither of the examples you give above work for me!) 0 Quote Link to comment Share on other sites More sharing options...
magga Posted December 12, 2008 Author Share Posted December 12, 2008 You should post an integration on here yourself in that case for Postcode Anywhere, I'm just sharing this with others. You don't have to use it if you don't like it! I used 5,000 as an example, they last for 1 year in any case. If you read the original post you will see it says "please note that it is in demo mode only at the moment so only the postcode ZZ99 or a Nottingham postcode e.g. NG1 1GA will work". 0 Quote Link to comment Share on other sites More sharing options...
ivaserver Posted December 13, 2008 Share Posted December 13, 2008 Thanks xperience for posting the postcodeanywhere info. I very nearly went for SimplyPostcode but postcodeanywhere with worldwide postcodes is what I needed. Thanks again 0 Quote Link to comment Share on other sites More sharing options...
XN-Matt Posted December 16, 2008 Share Posted December 16, 2008 Looks like a great idea but when I tried your register page it didn't find my or other postcodes I entered which I know are valid. Me too. Maybe a very old version of the RoyalMail PAF? 0 Quote Link to comment Share on other sites More sharing options...
XN-Matt Posted December 16, 2008 Share Posted December 16, 2008 Me too. Maybe a very old version of the RoyalMail PAF? Scrap that. Just re-read the initial post again and it seems to work rather well. 0 Quote Link to comment Share on other sites More sharing options...
magga Posted December 16, 2008 Author Share Posted December 16, 2008 Yeah, it's just in demo mode currently mainly because the credits would be gone in no time otherwise! 0 Quote Link to comment Share on other sites More sharing options...
XN-Matt Posted December 16, 2008 Share Posted December 16, 2008 It was my, must-read-even-when-should-be-sleeping error 0 Quote Link to comment Share on other sites More sharing options...
magga Posted December 16, 2008 Author Share Posted December 16, 2008 No problem! If you want to see it working correctly, let me know and I can temporarily take it out of demo mode for you. 0 Quote Link to comment Share on other sites More sharing options...
magga Posted December 16, 2008 Author Share Posted December 16, 2008 We use http://www.postcodeanywhere.co.uk - a much better system from what I can see. One simple line of code needed and provides worldwide postcodes as well as UK. Not sure how it compares on price. Do you actually use this along with WHMCS? From what I can see in the documentation it is not one simple line of code and looks like it would be fairly complicated to integrate with the full International postcode service. If you have got this working, would you care to share the link so I can take a look. Cheers 0 Quote Link to comment Share on other sites More sharing options...
XN-Matt Posted December 16, 2008 Share Posted December 16, 2008 (edited) We tested this last night (postcodesanywhere). One line of code and it works perfectly. You set everything up from their web interface, it pulls all the form fields and lets you select what goes where. Took 5 minutes to setup the test. Very impressive though. Edited December 16, 2008 by XN-Matt 0 Quote Link to comment Share on other sites More sharing options...
xperience Posted December 16, 2008 Share Posted December 16, 2008 Do you actually use this along with WHMCS? From what I can see in the documentation it is not one simple line of code and looks like it would be fairly complicated to integrate with the full International postcode service. If you have got this working, would you care to share the link so I can take a look. Cheers Yep - works a treat with a number of websites we run. I'll PM you a link (to avoid abuse) 0 Quote Link to comment Share on other sites More sharing options...
LemonBarley Posted December 16, 2008 Share Posted December 16, 2008 does this works in all country? 0 Quote Link to comment Share on other sites More sharing options...
magga Posted December 16, 2008 Author Share Posted December 16, 2008 Not currently however I am working on this. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.