Post by choccybox » Thu Sep 25, 2014 1:21 pm

Hi,

When displaying invoices through the order page for printing purposes some customer's first names and last names are on different lines e.g. as follows:

Joe
Bloggs
Address etc.

Instead of the correct:

Joe Bloggs
Address etc.

I looked into this problem and found this is because the customers who have their names on two lines have entered a space after there first name either when they entered it when making an account and/or when entering the first name in their address book.

My question is how can we remove the space so that their names will appear on one line instead of two?

Please note, i'm running 1.5.5.1, so if this bug has been address in a later version, please let me know.

Newbie

Posts

Joined
Wed Oct 31, 2012 8:08 pm

Post by SXGuy » Thu Sep 25, 2014 3:21 pm

It isn't the space between the name causing a problem, its the table width in your order page

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by choccybox » Thu Sep 25, 2014 3:29 pm

It definitely is the space after the first name which is causing the problem because if you manually delete the space that the customer put after their first name (when either creating an account or new address in their address book) it resolves the problem. However, manually removing spaces after the first name is not a reasonable solution because we do not want to do that each time a customer accidentally puts a space after their first name when they enter their name.

What is the solution to this?

Newbie

Posts

Joined
Wed Oct 31, 2012 8:08 pm

Post by SXGuy » Thu Sep 25, 2014 8:04 pm

admin/sale/order.php

Look around line 2430

Code: Select all

if ($order_info['shipping_address_format']) {
					$format = $order_info['shipping_address_format'];
				} else {
					$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
				}
Does yours match?

perhaps an extra space is casuing a line break between {firstname} and {lastname} im unsure.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by choccybox » Thu Sep 25, 2014 8:26 pm

Yes, ours is exactly as you pasted.

This problem is not caused by that, though. This is simply caused by customers accidentally entering a space at the end of the first name text field when they create an account or a new address in their address book. If they enter spaces on other fields the same thing happens, but the most common is the first name because they expect to write their full name and often hit the space bar to enter their last name then realize they only need to enter their first name then move on to enter their last name in the next text field and don't delete the space they made in the first name field.

Please try it and i'm sure you'll see the problem. It is the spaces that were inputted in the forms (creat account and/or address book) which is definitely causing the breaks on the invoice addresses and needs correcting.

Example of the space that a customer inputs which causes the break between first and last names:
space.jpg

space.jpg (12.27 KiB) Viewed 5650 times


Newbie

Posts

Joined
Wed Oct 31, 2012 8:08 pm

Post by Antoni4 » Thu Sep 25, 2014 9:15 pm

If you believe that space really is the problem, then wrap the data fields (such as $data['firstname']) with trim() on server side.
(when you are storing the data into database [file: catalog/model/checkout/order.php, function: addOrder])

Or if you do not want to edit OC standard files, then you can do it from template through JavaScript.

User avatar
New member

Posts

Joined
Sat Sep 29, 2012 7:03 am

Post by BOBKIM7080 » Thu Dec 11, 2014 5:44 am

I have same problem.
"choccybox" is correct.
Is there anybody solve this?
I just worry if I mess up the file by wrong place ()

User avatar
New member

Posts

Joined
Fri Aug 26, 2011 12:53 am


Post by gtoc » Fri Jan 09, 2015 12:37 pm

Hi, so glad someone found the cause of this as I couldn't figure it out.

Has anyone found a solution for this bug. I know I can go in and edit the customer but it would be great to find a permanent solution to save this step.

New member

Posts

Joined
Tue Apr 23, 2013 12:11 pm

Post by BOBKIM7080 » Sun Jan 11, 2015 6:05 am

It happen also happen for city
{city} {zone_code} {postcode}
If customer input "city_" result will be
{city}
{zone_code} {postcode}

User avatar
New member

Posts

Joined
Fri Aug 26, 2011 12:53 am


Post by gtoc » Mon Apr 13, 2015 3:38 pm

Bump to see if any of the code gurus out there have a solution for this?

New member

Posts

Joined
Tue Apr 23, 2013 12:11 pm

Post by zekin » Tue Apr 14, 2015 11:50 am

I have same problem for more than 2 years. I used to fix it manually in the database, then I found it annoying and just don't care anymore.

My OC sites:
Top Choice Variety
Tiny World


New member

Posts

Joined
Wed Nov 21, 2012 8:13 pm

Post by 12oclocker » Sun May 31, 2015 11:50 pm

Here is the fix, testing in version 1.4.9.5 only, you may have to modify for your version of opencart....

I search opencart install for text strings...
$this->request->post['firstname']
$this->request->post['shipping_firstname']

this shows us these files use the string...

\catalog\controller\checkout\address.php
\catalog\controller\checkout\guest_step_1.php
\catalog\controller\account\address.php
\catalog\controller\account\create.php
\catalog\controller\account\edit.php
\admin\controller\user\user.php
\admin\controller\sale\customer.php

//we will edit all files "EXCEPT" the admin files...
see attached files and see code notes as to how the fix was performed,
methodology can be used to fix any version of opencart if the problem exist in your version.

Active Member

Posts

Joined
Fri Feb 19, 2010 10:50 am

Post by BOBKIM7080 » Sat Jun 13, 2015 11:53 pm

Is anybody tried this method?
And what I have to change for 1.5.6

User avatar
New member

Posts

Joined
Fri Aug 26, 2011 12:53 am


Post by IP_CAM » Sun Jun 14, 2015 12:49 am

it's as easy as that: ;D

Ernie
bigmax.ch/shop/

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by BOBKIM7080 » Fri Jul 17, 2015 8:24 am

anybody find solution for v 1.5.6 ??

User avatar
New member

Posts

Joined
Fri Aug 26, 2011 12:53 am


Post by IP_CAM » Fri Jul 17, 2015 8:55 am

BOBKIM7080 wrote:anybody find solution for v 1.5.6 ??
On the image, above your Posting, you'll see the solution for v.1.5.6.x,
if you care, to look! ???

JUST place the lastname BELOW the firstname, that's it!
Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by BOBKIM7080 » Sat Aug 22, 2015 6:26 am

"choccybox"
Did you find solution?

User avatar
New member

Posts

Joined
Fri Aug 26, 2011 12:53 am

Who is online

Users browsing this forum: No registered users and 43 guests