Post by kryptonbulbs » Thu Apr 14, 2011 3:33 am

Searched and searched on how to do this, the best I could find would rearrange the format that you see on your invoice which I must have done when I first implemented opencart.

What this pertains to is the fields seen by the customer as they are filling out their address info.

In the US the standard format is:
Name (First, Last)
Company
Address (1)
Address (2)
City
Region / State (opencart calls this zone)
Postcode
Country

opencart is set up to put it in this order:
Name (First, Last)
Company
Address (1)
Address (2)
City
Postcode
Country
Region / State (opencart calls this zone)

This looks very confusing to US customers.

So, I went out to figure out how to "fix" this myself.

There are 2 areas that you will need to adjust, the guest area and the member area (unless you disallow one of them)

To fix the registered users area you will need to go to
Catalog/View/Theme/***THEME YOU ARE USING***/template/account/create.tpl

It should be pretty self explanitory BUT, you are looking for:

Code: Select all

<tr>
  <td><span class="required">*</span> <?php echo $entry_postcode; ?></td>
  <td><input type="text" name="postcode" value="<?php echo $postcode; ?>" />
  <?php if ($error_postcode) { ?>
  <span class="error"><?php echo $error_postcode; ?></span>
  <?php } ?></td>
</tr>
          <tr>
            <td><span class="required">*</span> <?php echo $entry_country; ?></td>
            <td><select name="country_id" id="country_id" onchange="$('select[name=\'zone_id\']').load('index.php?route=account/create/zone&country_id=' + this.value + '&zone_id=<?php echo $zone_id; ?>');">
                <option value="FALSE"><?php echo $text_select; ?></option>
                <?php foreach ($countries as $country) { ?>
                <?php if ($country['country_id'] == $country_id) { ?>
                <option value="<?php echo $country['country_id']; ?>" selected="selected"><?php echo $country['name']; ?></option>
                <?php } else { ?>
                <option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
                <?php } ?>
                <?php } ?>
              </select>
              <?php if ($error_country) { ?>
              <span class="error"><?php echo $error_country; ?></span>
              <?php } ?></td>
          </tr>
          <tr>
            <td><span class="required">*</span> <?php echo $entry_zone; ?></td>
            <td><select name="zone_id">
              </select>
              <?php if ($error_zone) { ?>
              <span class="error"><?php echo $error_zone; ?></span>
              <?php } ?></td>
          </tr>
And you will want to change it to this:

Code: Select all

 <tr>
            <td><span class="required">*</span> <?php echo $entry_zone; ?></td>
            <td><select name="zone_id">
              </select>
              <?php if ($error_zone) { ?>
              <span class="error"><?php echo $error_zone; ?></span>
              <?php } ?></td>
          </tr>

<tr>
  <td><span class="required">*</span> <?php echo $entry_postcode; ?></td>
  <td><input type="text" name="postcode" value="<?php echo $postcode; ?>" />
  <?php if ($error_postcode) { ?>
  <span class="error"><?php echo $error_postcode; ?></span>
  <?php } ?></td>
</tr>
          <tr>
            <td><span class="required">*</span> <?php echo $entry_country; ?></td>
            <td><select name="country_id" id="country_id" onchange="$('select[name=\'zone_id\']').load('index.php?route=account/create/zone&country_id=' + this.value + '&zone_id=<?php echo $zone_id; ?>');">
                <option value="FALSE"><?php echo $text_select; ?></option>
                <?php foreach ($countries as $country) { ?>
                <?php if ($country['country_id'] == $country_id) { ?>
                <option value="<?php echo $country['country_id']; ?>" selected="selected"><?php echo $country['name']; ?></option>
                <?php } else { ?>
                <option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
                <?php } ?>
                <?php } ?>
              </select>
              <?php if ($error_country) { ?>
              <span class="error"><?php echo $error_country; ?></span>
              <?php } ?></td>
          </tr>



Now on to the guest checkout...

You need to go to:
catalog/view/theme/***THEME YOU ARE USING***/template/checkout/guest_step_1orig.tpl

Here you will look for the following code:

Code: Select all


<tr>
            <td><?php echo $entry_postcode; ?></td>
            <td><input type="text" name="postcode" value="<?php echo $postcode; ?>" /></td>
          </tr>
          <tr>
            <td><span class="required">*</span> <?php echo $entry_country; ?></td>
            <td><select name="country_id" id="country_id" onchange="$('select[name=\'zone_id\']').load('index.php?route=checkout/guest_step_1/zone&country_id=' + this.value + '&zone_id=<?php echo $zone_id; ?>');">
                <option value="FALSE"><?php echo $text_select; ?></option>
                <?php foreach ($countries as $country) { ?>
                <?php if ($country['country_id'] == $country_id) { ?>
                <option value="<?php echo $country['country_id']; ?>" selected="selected"><?php echo $country['name']; ?></option>
                <?php } else { ?>
                <option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
                <?php } ?>
                <?php } ?>
              </select>
              <?php if ($error_country) { ?>
              <span class="error"><?php echo $error_country; ?></span>
              <?php } ?></td>
          </tr>
 <tr>
            <td><span class="required">*</span> <?php echo $entry_zone; ?></td>
            <td><select name="zone_id">
              </select>
              <?php if ($error_zone) { ?>
              <span class="error"><?php echo $error_zone; ?></span>
              <?php } ?></td>
          </tr>


                   
And Replace with:

Code: Select all

<tr>
            <td><span class="required">*</span> <?php echo $entry_zone; ?></td>
            <td><select name="zone_id">
              </select>
              <?php if ($error_zone) { ?>
              <span class="error"><?php echo $error_zone; ?></span>
              <?php } ?></td>
          </tr><tr>
            <td><?php echo $entry_postcode; ?></td>
            <td><input type="text" name="postcode" value="<?php echo $postcode; ?>" /></td>
          </tr>
          <tr>
            <td><span class="required">*</span> <?php echo $entry_country; ?></td>
            <td><select name="country_id" id="country_id" onchange="$('select[name=\'zone_id\']').load('index.php?route=checkout/guest_step_1/zone&country_id=' + this.value + '&zone_id=<?php echo $zone_id; ?>');">
                <option value="FALSE"><?php echo $text_select; ?></option>
                <?php foreach ($countries as $country) { ?>
                <?php if ($country['country_id'] == $country_id) { ?>
                <option value="<?php echo $country['country_id']; ?>" selected="selected"><?php echo $country['name']; ?></option>
                <?php } else { ?>
                <option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
                <?php } ?>
                <?php } ?>
              </select>
              <?php if ($error_country) { ?>
              <span class="error"><?php echo $error_country; ?></span>
              <?php } ?></td>
          </tr>

as well as find:

Code: Select all

<tr>
            <td><?php echo $entry_postcode; ?></td>
            <td><input type="text" name="shipping_postcode" value="<?php echo $shipping_postcode; ?>" /></td>
          </tr>
          <tr>
            <td><span class="required">*</span> <?php echo $entry_country; ?></td>
            <td><select name="shipping_country_id" id="shipping_country_id" onchange="$('select[name=\'shipping_zone_id\']').load('index.php?route=checkout/guest_step_1/zone&country_id=' + this.value + '&zone_id=<?php echo $zone_id; ?>');">
                <option value="FALSE"><?php echo $text_select; ?></option>
                <?php foreach ($countries as $country) { ?>
                <?php if ($country['country_id'] == $country_id) { ?>
                <option value="<?php echo $country['country_id']; ?>" selected="selected"><?php echo $country['name']; ?></option>
                <?php } else { ?>
                <option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
                <?php } ?>
                <?php } ?>
              </select>
              <?php if ($error_shipping_country) { ?>
              <span class="error"><?php echo $error_shipping_country; ?></span>
              <?php } ?></td>
          </tr>
          <tr>
            <td><span class="required">*</span> <?php echo $entry_zone; ?></td>
            <td><select name="shipping_zone_id">
              </select>
              <?php if ($error_shipping_zone) { ?>
              <span class="error"><?php echo $error_shipping_zone; ?></span>
              <?php } ?></td>
          </tr>
and replace with:

Code: Select all

<tr>
            <td><span class="required">*</span> <?php echo $entry_zone; ?></td>
            <td><select name="shipping_zone_id">
              </select>
              <?php if ($error_shipping_zone) { ?>
              <span class="error"><?php echo $error_shipping_zone; ?></span>
              <?php } ?></td>
          </tr>

<tr>
            <td><?php echo $entry_postcode; ?></td>
            <td><input type="text" name="shipping_postcode" value="<?php echo $shipping_postcode; ?>" /></td>
          </tr>
          <tr>
            <td><span class="required">*</span> <?php echo $entry_country; ?></td>
            <td><select name="shipping_country_id" id="shipping_country_id" onchange="$('select[name=\'shipping_zone_id\']').load('index.php?route=checkout/guest_step_1/zone&country_id=' + this.value + '&zone_id=<?php echo $zone_id; ?>');">
                <option value="FALSE"><?php echo $text_select; ?></option>
                <?php foreach ($countries as $country) { ?>
                <?php if ($country['country_id'] == $country_id) { ?>
                <option value="<?php echo $country['country_id']; ?>" selected="selected"><?php echo $country['name']; ?></option>
                <?php } else { ?>
                <option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
                <?php } ?>
                <?php } ?>
              </select>
              <?php if ($error_shipping_country) { ?>
              <span class="error"><?php echo $error_shipping_country; ?></span>
              <?php } ?></td>
          </tr>
          

To be honest, I dont think you even need to do the 1st code swap I outlined in the guest checkout, but I did it to begin with so I just figured I would put it in there.

Always do as I do and back up original files before changing them so you can return to default if you mess something up.

Glad I could finally contribute, I use alot of info from these forums.

Still need to figure out how to make customer fields searchable without depending on character Case (see other threads)

-Josh http://www.Kryptonbulbs.com

New member

Posts

Joined
Sat Jul 24, 2010 8:41 am

Post by mberlant » Thu Apr 14, 2011 3:43 am

Am I missing something? What version of OC are you using that requires this modification?

I just checked in 1.4.9.3's admin > system > localisation > countries, and opened the United States entry for edit. In the middle of the page is the "Address Format" block, which is already populated with:

{firstname} {lastname}
{company}
{address_1}
{address_2}
{city}, {zone} {postcode}
{country}

Is there somewhere you have noticed that does not pick up this format and use it wherever necessary?

Please use proper English at all times, so that all members may understand you.


User avatar
Active Member

Posts

Joined
Sun Mar 13, 2011 8:33 pm

Post by kryptonbulbs » Thu Apr 14, 2011 6:17 am

1.4.8b

Does it show correctly when customers go through it or just on your invoice, the section you are talking about in 1.4.8b only controls how it is output on the invoice, not on the input pages that the customer sees.

What is your site?


Edit, actually I am running 1.4.8 on Kryptonbulbs, I have 1.4.8b running on another site

New member

Posts

Joined
Sat Jul 24, 2010 8:41 am

Post by mberlant » Thu Apr 14, 2011 8:34 am

Ahhh... Now I understand what you are saying. The admin configuration only controls the output display for invoice, email, etc., but not for the registration input form.

The big reason that the registration input form is fixed is to allow the new customer to walk through the form from top to bottom, without skipping down to the bottom to choose his country and then backing up to choose his zone.

Naturally, PHP doesn't care how you organise the field order. So, it is up to you whether you want your new customers to see the fields in their "natural" order and have to skip over the zone box to choose his country first and then back up to choose his zone, or to walk through the fields from top to bottom while seeing them in an "unnatural" order.

Please use proper English at all times, so that all members may understand you.


User avatar
Active Member

Posts

Joined
Sun Mar 13, 2011 8:33 pm

Post by kryptonbulbs » Fri Apr 15, 2011 4:23 am

you got it, this was a big one for me. especially with zip code not being a required field, I had people skipping the zip code all the time. I made the zip code a required field in the regestered users checkout but couldnt get it to work in the guest checkout.

Anyhow, it just seems more "professional" to me to have it my way, I know if I was ordering something from a site with the format that was different than the US I would think this must be a company in a different country and that could influence my decision to buy based on security, and time frame to get products. Many US buyers are very afraid of international sites (in my opinion) .

Also, I believe country is prefilled isnt it? Im pretty sure I have it set to default to US which accounts for 90 to 95% of my orders

Just want to do what is best for my customers!

just passed 45K in sales this year on the site!

New member

Posts

Joined
Sat Jul 24, 2010 8:41 am

Post by kgkaraoke » Mon Apr 23, 2012 12:37 am

Nice try, but your modification has a SERIOUS bug.
The Postal code field no longer displays the mandatory red star.

ALWAYS checkout ALL suggested changes that you wish to publish BEFORE doing so!

New member

Posts

Joined
Fri Oct 29, 2010 9:06 am

Post by aerogel » Thu Aug 11, 2022 10:17 pm

mberlant wrote:
Thu Apr 14, 2011 3:43 am
Am I missing something? What version of OC are you using that requires this modification?

I just checked in 1.4.9.3's admin > system > localisation > countries, and opened the United States entry for edit. In the middle of the page is the "Address Format" block, which is already populated with:

{firstname} {lastname}
{company}
{address_1}
{address_2}
{city}, {zone} {postcode}
{country}

Is there somewhere you have noticed that does not pick up this format and use it wherever necessary?
thank you very much for your help (11 years later!). :P :P :P

New member

Posts

Joined
Thu Jan 04, 2018 8:14 pm
Who is online

Users browsing this forum: No registered users and 25 guests