Post by Qphoria » Fri Sep 04, 2009 12:30 am

Going to write this one and sticky it:

YOU DO NOT NEED TO APPLY THIS MOD IN 1.4.9 OR LATER AS IT HAS ALREADY BEEN ADDED AND AUTOMATICALLY REQUIRES BASED ON THE COUNTRY!

1. EDIT: catalog/controller/account/create.php
(If using v1.3.2 or newer)
FIND:

Code: Select all

if (isset($this->error['city'])) {
	$this->data['error_city'] = $this->error['city'];
} else {
	$this->data['error_city'] = '';
}
(If using v1.3.0 or older)
FIND:

Code: Select all

$this->data['error_city'] = @$this->error['city'];
AFTER, ADD: (ALL VERSIONS)

Code: Select all

if (isset($this->error['postcode'])) {
	$this->data['error_postcode'] = $this->error['postcode'];
} else {
	$this->data['error_postcode'] = '';
}

2. In that same file
FIND:

Code: Select all

if ((strlen(utf8_decode($this->request->post['city'])) < 3) || (strlen(utf8_decode($this->request->post['city'])) > 128)) {
      	$this->error['city'] = $this->language->get('error_city');
}
AFTER, ADD:

Code: Select all

if ((strlen(utf8_decode($this->request->post['postcode'])) < 1) || (strlen(utf8_decode($this->request->post['postcode'])) > 10)) {
      	$this->error['postcode'] = $this->language->get('error_postcode');
}
3. EDIT: catalog/language/english/account/create.php
FIND:

Code: Select all

$_['error_city']           = 'City must be greater than 3 and less than 128 characters!';
AFTER, ADD:

Code: Select all

$_['error_postcode']       = 'Postcode must be greater than 1 and less than 10 characters!';
4. EDIT: catalog/view/theme/default/template/account/create.tpl
FIND:

Code: Select all

<tr>
  <td><?php echo $entry_postcode; ?></td>
  <td><input type="text" name="postcode" value="<?php echo $postcode; ?>" /></td>
</tr>
REPLACE WITH:

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>

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by itrends » Fri Sep 04, 2009 12:58 am

Thanks but I cant even find the first line with the if in the folder that you mentioned.
Has this changed in the latest version perhaps as all I can find is:

if ((strlen(utf8_decode($this->request->post['city'])) < 3) || (strlen(utf8_decode($this->request->post['city'])) > 128)) {
$this->error['city'] = $this->language->get('error_city');
}

Active Member

Posts

Joined
Tue Jul 14, 2009 7:54 pm

Post by Qphoria » Fri Sep 04, 2009 1:47 am

ok i updated it for older versions of OpenCart

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by gladiator » Sat Sep 05, 2009 2:17 am

This works on the "initial" customer setup BUT If you add extra or multiple locations to that users account the zip code field is "not" a required field in that situation. Can you revise this post to make the zip code a required field when adding multiple locations to a user account as well?

http://www.gladiatorlighting.com


User avatar
New member

Posts

Joined
Wed Aug 12, 2009 1:26 pm

Post by fido-x » Sat Sep 05, 2009 3:50 pm

gladiator wrote:This works on the "initial" customer setup BUT If you add extra or multiple locations to that users account the zip code field is "not" a required field in that situation. Can you revise this post to make the zip code a required field when adding multiple locations to a user account as well?
Follow these steps to fix the other files.

1. Make the same changes that you made in "catalog/controller/account/create.php" to -- "catalog/controller/account/address.php" and "catalog/controller/checkout/address.php"

2. Make the same changes that you made in "catalog/language/english/account/create.php" to -- "catalog/language/english/account/address.php" and "catalog/language/english/checkout/address.php"

3. Make the same changes that you made in "catalog/view/theme/default/template/account/create.tpl" to -- "catalog/view/theme/default/template/account/address.tpl" and "catalog/view/theme/default/template/checkout/address.tpl"

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by gladiator » Sun Sep 06, 2009 3:23 pm

Fido-X

Thanks this worked great!

http://www.gladiatorlighting.com


User avatar
New member

Posts

Joined
Wed Aug 12, 2009 1:26 pm

Post by amplifywebdesign » Thu Sep 10, 2009 9:10 pm

Awesome thanks for this

User avatar
New member

Posts

Joined
Sat Aug 22, 2009 1:56 am
Location - Sheffield & North Wales

Post by JackHackett » Mon Oct 12, 2009 11:08 pm

Great work thanks to you both!

Whilst implementing this in v1.3.2 I discovered a couple of small validation errors in "catalog/controller/checkout/address.php", the maximum lengths are wrong for "address_1" and "city".

Search for:

Code: Select all

    	if ((strlen(utf8_decode($this->request->post['address_1'])) < 3) || (strlen(utf8_decode($this->request->post['address_1'])) > 64)) {
      		$this->error['address_1'] = $this->language->get('error_address_1');
    	}

    	if ((strlen(utf8_decode($this->request->post['city'])) < 3) || (strlen(utf8_decode($this->request->post['city'])) > 32)) {
      		$this->error['city'] = $this->language->get('error_city');
    	} 
and replace both the "64" and "32" with "128".

EDIT

My mistake the validation is different for the checkout code :-[

Newbie

Posts

Joined
Mon Oct 12, 2009 5:37 pm

Post by ctellier » Tue Oct 20, 2009 10:47 am

Thanks Guys, works great! :)

User avatar
New member

Posts

Joined
Sun Oct 18, 2009 9:36 am
Location - Wisconsin

Post by Rafael » Fri Nov 06, 2009 5:53 am

When checking out (OpenCart 1.3.2), and at delivery information I clicked on "change address"

This is the fault:

Notice: Undefined variable: error_postcode in catalog/view/theme/default/template/checkout/address.tpl on line 70

Normal:

Code: Select all

        <tr>
          <td><?php echo $entry_postcode; ?></td>
          <td><input type="text" name="postcode" value="<?php echo $postcode; ?>" /></td>
        </tr>
        <tr>
Changed:

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>
What is wrong here?

This is line 70: <?php if ($error_postcode) { ?>

User avatar
Newbie

Posts

Joined
Fri Feb 08, 2008 2:11 am
Location - Rotterdam - Netherlands

Post by Qphoria » Fri Nov 06, 2009 6:22 am

You missed a step. start over

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Rafael » Fri Nov 06, 2009 7:48 am

Qphoria wrote:You missed a step. start over
Your are right! :-*

I made a mistake, that is because I am getting older and older.

Thanks Q! ;)

User avatar
Newbie

Posts

Joined
Fri Feb 08, 2008 2:11 am
Location - Rotterdam - Netherlands

Post by Megabozz » Wed Nov 18, 2009 5:13 am

Does this work using guest checkout as well?

Newbie

Posts

Joined
Wed Nov 18, 2009 12:19 am
Location - Texas

Post by Qphoria » Wed Nov 18, 2009 5:14 am

Well you'd need to make the changes in the guest.php file.. they should be similar.
My v1.3.2 Guest Checkout already includes this

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by zollgut » Tue Nov 24, 2009 10:00 pm

Exactly what I needed, thanks for that guys.

One question, is it possible to only have the postcode as a required field for UK customers (i.e uk addresses selected for delivery address)?

Many Thanks!
:)

New member

Posts

Joined
Sat Sep 26, 2009 3:00 am

Post by Qphoria » Tue Nov 24, 2009 11:24 pm

zollgut wrote:Exactly what I needed, thanks for that guys.

One question, is it possible to only have the postcode as a required field for UK customers (i.e uk addresses selected for delivery address)?

Many Thanks!
:)
You'd be better off making it not required for the few countries that don't use it since they are the minority.

But I'm sure by now that these tiny countries that don't use postcodes have gotten used to entering '00000' or 'XXXX' or 'N/A' into the postcode field. So I wouldn't worry about it.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by i2Paq » Wed Nov 25, 2009 3:00 am

I would like to have it required as well ;)

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by vimal » Thu Dec 10, 2009 5:23 am

Hi Q!

It is a very useful mod. However, I get this error in the error log repeated many times.

2009-11-25 21:21:20 - PHP Notice: Undefined variable: error_postcode in /home/web75231/domains/seagren.se/public_html/catalog/view/theme/seagren/template/account/address.tpl on line 41

What is the problem? How can I get rid of it?

www.beeshop.se
Starta webbshop, Starta e-butik, Starta e-handel


Active Member

Posts

Joined
Wed Aug 26, 2009 8:54 am
Location - Sweden

Post by Qphoria » Thu Dec 10, 2009 5:49 am

you missed a step i'd guess

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by montanaflynn » Tue Dec 15, 2009 3:31 am

One thing I didn't see mentioned is you should do all the steps for guest checkout as well if your install supports guest checkouts.

Do everything you did for catalog/account/create to catalog/checkout/guest, the view, controller, and language files are all very similar so it should be pretty straightforward without another guide being written up.

Thanks Q!

PS: I also changed my language files to be more user friendly, the exclamation points after every error was a negative IMO.

User avatar
New member

Posts

Joined
Fri Oct 09, 2009 5:19 am
Who is online

Users browsing this forum: No registered users and 131 guests