Jump to content

Alter address to UK address format (files included) and also add county/state text field


Recommended Posts

I have created the files necessary to alter your prestashop address to the UK format.

The files also include the instructions and necessary code to add a new field for states/counties which will be a text field rather than a drop down menu. (It also removes the dropdown menu.)

The formatting will be for your whole site, frontend, backend and pdf invoices.

There is a readme with instructions on how to create a new field in your mysql database, so you will need access to be able to do this.

The files that need to be uploaded are saved in the folders that they will need to be uploaded too.

But just incase you don't understand I will list them below.

I am available to install the files and do the necessary mysql changes for you, but I will be charging £10 for this.

Any upgrades to the files from prestashop.com (SVN or a software upgrade) will obviously overwrite any changes that have been made in the files. I wouldn't advise uploading the files again as other sections of the code could have changed, which could affect the stabilty of your site.

admin>tabs

Adminaddress
Adminorders

classes

address.php
pdf.php

Yourthemefolder

address.tpl
addresses.tpl
authentication.tpl
order-address.tpl
order-detail.tpl
shopping-cart.tpl

If you have any problems with this please contact me via this forum or email Jhnstcks at AOL dot com

If you have already performed the sql editting on a previous version of prestashop then you will NOT need to perform it again as the field will still be in the database.

New version for 1.3.1 included.

UK address format 1.3.1.zip

Address Format 1.3.1 Dropdown menu.zip

Link to comment
Share on other sites

A few things to add to this.

If you are using this to create the text entry field for state/county then obviously it is going to be empty for your existing customers, so if you want to transfer the county/state over you will need to note down their county/state then alter it manually in your admin area.

If anyone wants a different address layout then I can now easily change this and upload a new version for other countries.

While I was changing the code I also found the small bit of code that causes the surname/last name to becoming call captials, if anyone is interested I can post that here too.

Link to comment
Share on other sites

I'm from the Uk and this would be handy, i changed the files with the new ones and tried a new account and i get this error when i try to register,

There is 1 error:
1.an error occurred while creating your address

I have tried this on 1.1 and the new 1.2 version, any help will be appreciated.

Thanks,

Mark.

Link to comment
Share on other sites

Thankyou, my fault sorry it works now.

Just one other thing when you go through the checkout process and you are on the adresses page it doesn't show the correct address, its still the old version way, but click on my addresses in my account and everything is ok.

Maybe its just me.

Thanks,

Mark.

Link to comment
Share on other sites

  • 2 weeks later...

Hello,

Very nice module but I have a problem.

I installed in accordance with your readme file and all appeared well until I tried to go to "orders" in the back office. All I get is a message saying "Bad SQL query".

Once I restored my install to the backed up version this error disappeared. I tried again but go the same result. What could the problem be?

Thank you

Link to comment
Share on other sites

Ive restored the original pdf.php to the "classes" folder and my pdfs open again all be it with the wrong format for the addresses. I mean if you upgrade to 1.1 and do this again its a great modification but for now Im quite happy. Thanks for your help with the back office thing.

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...

Hello Prestausers,

Can someone help me with the following.
I want to add the costumers e-mail adress on the invoice under delivery adress.
Eg
Name
Adress
Postalcode City
Country
Phone
e-mail address

Can someone help me please???

Thanks in advance.

Regards,

Edi

Link to comment
Share on other sites

  • 5 weeks later...

Thank you for an excellent contribution, for us in the UK this really is usefull. Like all the other contributors, it is a shame about the PDF's not working. I am currently undertaking a site for a client and decided to use Prestashop instead of my old favourite Zen Cart and I must say that I am impressed and believe with the support of the community this open sources software will have a great future, providing it does not get all commercial. However if anyone can let me know if there is a fix for the blank PDF invoice and shipping note using this mod. in Prestashop 1.1 I would be very grateful. Other than this it is an excellent piece of work for the UK and will save a lot of problems with the address format.

Look forward to hearing from you all.

Best regards

Link to comment
Share on other sites

OK I have almost sorted out the PDF's for 1.1, however I would like to start changing the address format on the order confirmation email html file. I managed to re-arrange the fields but cannot add the county field, I have tied adding {delivery_county} to the html but nothing happns. I cannot find where variables / tags such as invoice_postal_code are populated from.

Anyhelp would be appreciated, once I have worked out all the other areas not covered by this excellent contribution and get them working properly, I will post the files on the forum.

Link to comment
Share on other sites

  • 1 month later...
  • 4 weeks later...

Actually 'County' was dropped a long time ago. The usual UK postal address format is:

Name
Address1
Address2
Locality/Suburb (optional in most cases)
City
Postcode
Country

At this this is the case with the Royal Mail. Now what really screws things up is couriers requiring extra information not normally captured in the address. Particularly annoying is when they insist on counties for major cities becuase their input form requires one.

Link to comment
Share on other sites

Hi, I am just wondering is it possilbe to have this seperate from the origional contact us, what I mean is I want to have 2 contact us forms, keep the origional and add an extra contact form as form2.
Is this possilbe? Do I have to change the code, or just rename the files and link to it?

Please help, thank you.

Link to comment
Share on other sites

Actually 'County' was dropped a long time ago. The usual UK postal address format is:

Name
Address1
Address2
Locality/Suburb (optional in most cases)
City
Postcode
Country

At this this is the case with the Royal Mail. Now what really screws things up is couriers requiring extra information not normally captured in the address. Particularly annoying is when they insist on counties for major cities becuase their input form requires one.


This is quite true although it does require that the post town and postcode also be present on the address.
Link to comment
Share on other sites

We always look up the addresses by postcode (and yes it does supply the county information as well but it is not always accurate so we don't tend to use it on the postage labels). If we change our Prestashop to UK address format then it would be wrong for our overseas customers.

I am looking forward to the day when Prestashop supports international address formats. I haven't seen this on the feature list yet but I see they are starting to think internationally as regard to legislation so I expect this will come soon.

Link to comment
Share on other sites

Yes I am wondering if it would be simpler to export orders to another program to do the routine stuff like producing invoices and packing slips. Actually there are only really a few address formats in use in Europe so it is simply a case of defining the format for each country. It doesn't even matter if the invoice is not in pdf format, as there are plenty of free programs that will do the conversion.

Link to comment
Share on other sites

  • 3 months later...
I have created the files necessary to alter your prestashop address to the UK format.

The files also include the instructions and necessary code to add a new field for states/counties which will be a text field rather than a drop down menu. (It also removes the dropdown menu.)

The formatting will be for your whole site, frontend, backend and pdf invoices.

There is a readme with instructions on how to create a new field in your mysql database, so you will need access to be able to do this.

The files that need to be uploaded are saved in the folders that they will need to be uploaded too.

But just incase you don't understand I will list them below.

I am available to install the files and do the necessary mysql changes for you, but I will be charging £10 for this.

Any upgrades to the files from prestashop.com (SVN or a software upgrade) will obviously overwrite any changes that have been made in the files. I wouldn't advise uploading the files again as other sections of the code could have changed, which could affect the stabilty of your site.

admin>tabs

Adminaddress
Adminorders

classes

address.php
pdf.php

Yourthemefolder

address.tpl
addresses.tpl
authentication.tpl
order-address.tpl

If you have any problems with this please contact me via this forum or email Jhnstcks at AOL dot com

Edit: I have added created 2 different versions, 1 with the dropdown counties menu and one with the text entry field which will need to sql editting as mentioned above.

If you have already performed the sql editting on a previous version of prestashop then you will NOT need to perform it again as the field will still be in the database.


I have problem with it, It does not working for me I did exactly what readme said but I was unsuccessful, I am using prestashop Version 1.3.0.1
PLEASE HELP ME
Link to comment
Share on other sites

  • 3 weeks later...
  • 4 weeks later...

Yeah, I agree. It would a fantastic and up to date feature, no one really type there address in any more for uk website. They add their Post Code and click "CHECK" and the choose their house number. The rest is pre-filled.

Link to comment
Share on other sites

  • 3 months later...
  • 3 weeks later...

Hi jhnstcks,
Can you please tell me how to do the format for the United States (back office and front office)? I need it like this:

Name
Address
City, State, Postal Code

I don't need the country shown because I am only shipping to the united states (online). If someone else knows how please post? Or should I make a new brand new post for the United States format?

Thanks!
7:)

Link to comment
Share on other sites

  • 1 month later...

Hi jhnstcks, and thanks for a useful solution.

The only problem I am having with your v1.3.1 files, is that on checkout, the information entered in the County field, is not passed on to Paypal.

Paypal displays the customer address without the County, so the customer thinks they haven't entered their full address.

Is there any way around this that you can think of?

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Hi there!

I've just installed this mod - thank you very much, saved me a lot of time to manually work it through myself!!

The only issue I'm having is with the .pdf - as someone previously mentioned I'm just getting a white screen, but restoring it to the previous one I had works fine! Any ideas why this happens? I would of thought only a couple of lines with the addresses would need to be added/moved around?

Link to comment
Share on other sites

This is quite a nice change however i am using v1.3.1 and utlising the states within the UK to set diffrent pricing for Highlands & Island. Therefore i would really appreciate a version that has dropdown menu so that the postage can be calculated correctly.
I currently get an error message 'this country require a state selection' but the state section is now longer showing

#Update#

I have put the files back as they were to show you

Using states within the UK
http://dl.dropbox.com/u/6962833/address1.png

How the address currently displays and how i would like it
http://dl.dropbox.com/u/6962833/address2.png

Thanks

Link to comment
Share on other sites

Thanks for that, drop down working perfect.

however i wonder if you are able to tidy up the format it brings back

See below for how it currently looks
http://dl.dropbox.com/u/6962833/address_format.jpg

What would be perfect would be to hide the State/County from the address as i am only using that field for calculation of shipping costs.
also to have the UK part after the postcode on a separate line

Much appreciated if you could help me out :)

Link to comment
Share on other sites

How about if i add the drop-down menu back into the previous version with the text entry field, but move the drop down to the bottom of the login page and remove it from all other pages.

or

Leave the dropdown in the login page but move it to the bottom, and remove that field from other pages?

Link to comment
Share on other sites

That address is controlled by 2 files order-address.js and order-address.tpl.

In order-address.js find the following

function updateAddressDisplay(addressType)
{
   var idAddress = $('select#id_address_' + addressType + '').val();
   $('ul#address_' + addressType + ' li.address_company').html(addresses[idAddress][0]);
   if(addresses[idAddress][0] == '')
       $('ul#address_' + addressType + ' li.address_company').hide();
   else
       $('ul#address_' + addressType + ' li.address_company').show();
   $('ul#address_' + addressType + ' li.address_name').html(addresses[idAddress][1] + '' + addresses[idAddress][2]);
   $('ul#address_' + addressType + ' li.address_address1').html(addresses[idAddress][3] +',');
   $('ul#address_' + addressType + ' li.address_address2').html(addresses[idAddress][4] +',');
   if(addresses[idAddress][4] == '')
       $('ul#address_' + addressType + ' li.address_address2').hide();
   else
       $('ul#address_' + addressType + ' li.address_address2').show();
   $('ul#address_' + addressType + ' li.address_city').html(addresses[idAddress][6] + ' , ' + addresses[idAddress][8] +',');
   $('ul#address_' + addressType + ' li.address_country').html(addresses[idAddress][5] + ' , ' + (addresses[idAddress][7] != '' ? ' ' + addresses[idAddress][7] +'.' : ''));
   $('ul#address_' + addressType + 'li.address_country').html(addresses[idAddress][7] +'.');
   // change update link
   var link = $('ul#address_' + addressType + ' li.address_update a').attr('href');
   var expression = /id_address=\d+/;
   link = link.replace(expression, 'id_address='+idAddress);
   $('ul#address_' + addressType + ' li.address_update a').attr('href', link);
}



and change it too:

function updateAddressDisplay(addressType)
{
   var idAddress = $('select#id_address_' + addressType + '').val();
   $('ul#address_' + addressType + ' li.address_company').html(addresses[idAddress][0]);
   if(addresses[idAddress][0] == '')
       $('ul#address_' + addressType + ' li.address_company').hide();
   else
       $('ul#address_' + addressType + ' li.address_company').show();
   $('ul#address_' + addressType + ' li.address_name').html(addresses[idAddress][1] + '' + addresses[idAddress][2]);
   $('ul#address_' + addressType + ' li.address_address1').html(addresses[idAddress][3] +',');
   $('ul#address_' + addressType + ' li.address_address2').html(addresses[idAddress][4] +',');
   if(addresses[idAddress][4] == '')
       $('ul#address_' + addressType + ' li.address_address2').hide();
   else
       $('ul#address_' + addressType + ' li.address_address2').show();
   $('ul#address_' + addressType + ' li.address_city').html(addresses[idAddress][6] + ' , ' + addresses[idAddress][8] +',');
   $('ul#address_' + addressType + ' li.address_postcode').html(addresses[idAddress][5] + ',');
   $('ul#address_' + addressType + ' li.address_country').html(addresses[idAddress][7] +'.');

   // change update link
   var link = $('ul#address_' + addressType + ' li.address_update a').attr('href');
   var expression = /id_address=\d+/;
   link = link.replace(expression, 'id_address='+idAddress);
   $('ul#address_' + addressType + ' li.address_update a').attr('href', link);
}



in order-address.tpl find the following:

>


</pre>
<ul>
{l s='Your delivery address'}






{l s='Update'}
</ul>
<br><ul>
{l s='Your billing address'}








and change it too:

>        </pre>
<ul>
{l s='Your delivery address'}







{l s='Update'}
</ul>
<br><ul>
{l s='Your billing address'}







Link to comment
Share on other sites

Hi jhnstcks,

On the order_conf email I'm currently recieving the variable '{delivery_county}' and '{invoice_county}' instead of the actual county.

I've looked at all of the other files and all of the files you zipped have the correct coding and all seem to work fine! Any ideas?

Link to comment
Share on other sites

Hi jhnstcks,

On the order_conf email I'm currently recieving the variable '{delivery_county}' and '{invoice_county}' instead of the actual county.

I've looked at all of the other files and all of the files you zipped have the correct coding and all seem to work fine! Any ideas?


Try this -> http://www.prestashop.com/forums/viewthread/18112/P45/#300135
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...

Ok ignore my original question below, I ran it through DiffMerge again and found one section where 'county' was not included. I can confirm that this works (so far) with prestashop v.1.3.3, I have not finished fully testing it yet so I will update again when it is done.

It seems you cannot copy and replace the file like you could with previous versions of prestashop. If anyone would like to use with with v.1.3.3 they you will need to compare the two files and only add in the necessary code.

Thanks John for the code for this, it is excellent!

Hi John,

I used your code on prestashop v.1.2 and it worked a treat. I have now upgraded to v.1.3.3 and it unfortunately doesn't work. I have been comparing the new v.1.3.3 files to the ones that worked in v.1.2 using DiffMerge so I can see the differences. When I copied it the old files across the website just displayed a white screen and I have found there are many pieces of new code in the latest release. I have manually added all the bits I need to from the old files but when updating the address (or creating a new one) it does not add the County Field to the database for some reason. I don't suppose you have tried this with v1.3.3?

I have had a play if I add a value in the county filed in the database it will show front end. However if I try to edit this field in the customer account it deletes out the field completely. I have also tried this in the admin panel and that seems ok. I can add and change in the admin panel succefully so it must just be an issue with the address.php file (in the classes folder) but I have hit a brick wall.

Anything I can check to resolve this? I hope that's clear. If not give me a shout and I will be happy to try and clarify anything!

Any help will be gratefully received!
Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...

Hi,

I have successfully changed over the address to the UK format following this guide a number of times, but this time I seem to get a syntax error when I use your SQL statement to add the 'county' field to the database - has something changed in version 1.3.7?

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...