Hi,
I have been struggeling with this quite some time now.
I live in Sweden and we have no use for Zone/Region/State, but in Opencart you need it for shipping, tax and other extensions and modules to work.
I have read this thread http://forum.opencart.com/viewtopic.php?f=20&t=25808 and this one http://forum.opencart.com/viewtopic.php?t=8349
But I don't get it to work properly. And in 1.5 I cant find this file: controller/account/create.php
I made it to a point where it automaticly select a Zone if you have country set to Sweden, but I need it to hide aswell!
From this point I started to get error messages.
If someone could make a nice and clear description for this for opencart 1.5 it would be great!
Also, is there no reason to add some features in the coming updates that can make you choose what information you need from people signing up or using the guest checkout.
I know many people want to remove many fields and some people want to make fields not required to fill out.
I have been struggeling with this quite some time now.
I live in Sweden and we have no use for Zone/Region/State, but in Opencart you need it for shipping, tax and other extensions and modules to work.
I have read this thread http://forum.opencart.com/viewtopic.php?f=20&t=25808 and this one http://forum.opencart.com/viewtopic.php?t=8349
But I don't get it to work properly. And in 1.5 I cant find this file: controller/account/create.php
I made it to a point where it automaticly select a Zone if you have country set to Sweden, but I need it to hide aswell!
From this point I started to get error messages.
If someone could make a nice and clear description for this for opencart 1.5 it would be great!
Also, is there no reason to add some features in the coming updates that can make you choose what information you need from people signing up or using the guest checkout.
I know many people want to remove many fields and some people want to make fields not required to fill out.
Last edited by i2Paq on Wed Jun 22, 2011 12:03 am, edited 1 time in total.
Reason: Use [version] TAG in subject!
Reason: Use [version] TAG in subject!
This worked for me in 1.5, it's quite quick and easy. You need to modify both controller files and view files for three different scenarios;
1. Guest checkout
2. Account creation during checkout
3. Account creation without checkout (also when editing address in account page)
To remove from guest checkout:
In /catalog/controller/checkout/guest.php
Find (should be around line 58)
and either comment that out or delete.
In /catalog/view/theme/YOURTHEME/template/checkout/guest.tpl
Find (should be around line 59)
and either comment that out or delete.
In /catalog/view/theme/YOURTHEME/template/checkout/guest_shipping.tpl
Find (should be around line 43)
and either comment that out or delete. And add the following in that spot:
To remove from account creation during checkout:
In /catalog/controller/checkout/register.php
Find (should be around line 60)
and either comment that out or delete.
In /catalog/controller/checkout/address.php
Find two instances of (should be around line 62 AND line 192)
and either comment that out or delete.
In /catalog/view/theme/YOURTHEME/template/checkout/register.tpl
Find (should be around line 69)
and either comment that out or delete.
In /catalog/view/theme/YOURTHEME/template/checkout/address.tpl
Find (should be around line 63)
and either comment that out or delete. And add the following in that spot:
To remove from account creation without checkout:
In /catalog/controller/account/register.php
Find (should be around line 322)
and either comment that out or delete.
In /catalog/controller/account/address.php
Find (should be around line 466)
and either comment that out or delete.
In /catalog/view/theme/YOURTHEME/template/account/register.tpl
Find (should be around line 99)
and either comment that out or delete. And add the following in that spot:
In /catalog/view/theme/YOURTHEME/template/account/address_form.tpl
Find (should be around line 72)
and either comment that out or delete. And add the following in that spot:
That should do it! I apologize for the long post, but I wanted to make it clear so that everyone can follow along. Give me a shout if I missed something!
1. Guest checkout
2. Account creation during checkout
3. Account creation without checkout (also when editing address in account page)
To remove from guest checkout:
In /catalog/controller/checkout/guest.php
Find (should be around line 58)
Code: Select all
if ($this->request->post['zone_id'] == '') {
$json['error']['zone'] = $this->language->get('error_zone');
}
In /catalog/view/theme/YOURTHEME/template/checkout/guest.tpl
Find (should be around line 59)
Code: Select all
<span class="required">*</span> <?php echo $entry_zone; ?><br />
<select name="zone_id" class="large-field">
</select>
In /catalog/view/theme/YOURTHEME/template/checkout/guest_shipping.tpl
Find (should be around line 43)
Code: Select all
<tr>
<td><span class="required">*</span> <?php echo $entry_zone; ?></td>
<td><select name="zone_id" class="large-field">
</select></td>
</tr>
Code: Select all
<input type="hidden" name="zone_id" value="0" />
To remove from account creation during checkout:
In /catalog/controller/checkout/register.php
Find (should be around line 60)
Code: Select all
if ($this->request->post['zone_id'] == '') {
$json['error']['zone'] = $this->language->get('error_zone');
}
In /catalog/controller/checkout/address.php
Find two instances of (should be around line 62 AND line 192)
Code: Select all
if ($this->request->post['zone_id'] == '') {
$json['error']['zone'] = $this->language->get('error_zone');
}
In /catalog/view/theme/YOURTHEME/template/checkout/register.tpl
Find (should be around line 69)
Code: Select all
<span class="required">*</span> <?php echo $entry_zone; ?><br />
<select name="zone_id" class="large-field">
</select>
In /catalog/view/theme/YOURTHEME/template/checkout/address.tpl
Find (should be around line 63)
Code: Select all
<tr>
<td><span class="required">*</span> <?php echo $entry_zone; ?></td>
<td><select name="zone_id" class="large-field">
</select></td>
</tr>
Code: Select all
<input type="hidden" name="zone_id" value="0" />
To remove from account creation without checkout:
In /catalog/controller/account/register.php
Find (should be around line 322)
Code: Select all
if ($this->request->post['zone_id'] == '') {
$this->error['zone'] = $this->language->get('error_zone');
}
In /catalog/controller/account/address.php
Find (should be around line 466)
Code: Select all
if ($this->request->post['zone_id'] == '') {
$this->error['zone'] = $this->language->get('error_zone');
}
In /catalog/view/theme/YOURTHEME/template/account/register.tpl
Find (should be around line 99)
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>
Code: Select all
<input type="hidden" name="zone_id" value="0" />
In /catalog/view/theme/YOURTHEME/template/account/address_form.tpl
Find (should be around line 72)
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>
Code: Select all
<input type="hidden" name="zone_id" value="0" />
Thanks! It seems to work, going to test it once more.
Probably catalog\view\Theme\YOUR THEME\template\total\shipping.tpl can use this magic as well. It's the shipping estimator:
Around line 19 this code:
replaced by:
Probably catalog\view\Theme\YOUR THEME\template\total\shipping.tpl can use this magic as well. It's the shipping estimator:
Around line 19 this code:
Code: Select all
<tr>
<td><span class="required">*</span> <?php echo $entry_zone; ?></td>
<td><select name="zone_id">
</select></td>
</tr>
Code: Select all
<input type="hidden" name="zone_id" value="0" />
I can't get it to work, I use a custom theme and my .tpl don't look like the original.
This is the code related to country/zone in my /checkout/guest.tpl
If I just remove the code that makes the Zone field it don't shows when a guest checks out, but when I klick continue in the checkout process to get to delivery info it just stops.
I think the code I removed just removes the javascript requirement of Zone(maybe theme related), so I don't get an error message. But something else prevents the field to be accepted.
This is the code related to country/zone in my /checkout/guest.tpl
Code: Select all
<div class="s_row_2 clearfix">
<label><?php echo $entry_zone; ?> *</label>
<select id="zone_id" name="zone_id" class="required"></select>
</div>
I think the code I removed just removes the javascript requirement of Zone(maybe theme related), so I don't get an error message. But something else prevents the field to be accepted.
Hi again, I think I solved the problem, I just need to test it and edit all the template files.
I simply put inside the select tag for the Zone. And removed the text before it.
Original "Zone code" in template file:
edited to:
I have seen other teplates/themes with the exact same codes for zones, so I hope this will help others... if it works!
Now, as a rookie on coding I pray this will work.
I simply put
Code: Select all
style="display:none;"
Original "Zone code" in template file:
Code: Select all
<div class="s_row_2 clearfix">
<label><?php echo $entry_zone; ?> *</label>
<select id="zone_id" name="zone_id" class="required"></select>
</div>
Code: Select all
<div class="s_row_2 clearfix">
<select style="display:none;" id="zone_id" name="zone_id"></select>
</div>

Now, as a rookie on coding I pray this will work.
Goffer wrote:Finally!
A working solution that i could do![]()
But, it stills says Region/State when in checkout, and you choose not to use an existing address, or did i skip something in the tutorial?
I got the same thing, but I used AstroGrep and searched for this code in a localy stored bakup of my site.
Code: Select all
if ($this->request->post['zone_id'] == '') {
$json['error']['zone'] = $this->language->get('error_zone');
}
Found that it still remained in
catalog/controller/checkout/adress.php
catalog/controller/checkout/guest.php
catalog/controller/total/shipping.php
now I don't get any error messages and no Zone appear anywhere... so far

Thank you all for this solution. Was a great help.
I didn't want to rewrite the source code so I made the above corrections into a vqmod file. It is the first time i tried to make a vqmod file so please let me know if you have any problems with it.
Remember to replace YOURTHEME with the name of your template.
Good luck with it!
UPDATE
I tested it with Opencart v1.5.1.3. It seems to work if you register an account. But it doesnt work on guest checkout as you cant get any further when you push the continue button. As far as I have found out, it is because the zone is set to --- Please select --- and not the prefered zone.
If somebody can come up with a solution to set the zone to a default area insteadt of --- please select --- then it should work.
I have tried to figure this one out but I am not a programmer. So any help on this will be appreciated
I didn't want to rewrite the source code so I made the above corrections into a vqmod file. It is the first time i tried to make a vqmod file so please let me know if you have any problems with it.
Remember to replace YOURTHEME with the name of your template.
Good luck with it!
UPDATE
I tested it with Opencart v1.5.1.3. It seems to work if you register an account. But it doesnt work on guest checkout as you cant get any further when you push the continue button. As far as I have found out, it is because the zone is set to --- Please select --- and not the prefered zone.
If somebody can come up with a solution to set the zone to a default area insteadt of --- please select --- then it should work.
I have tried to figure this one out but I am not a programmer. So any help on this will be appreciated

Attachments
Remove state/region vqmod
Last edited by zippen on Wed Oct 12, 2011 5:17 pm, edited 2 times in total.
Here is a solution that works for all countries, with 1.5.1. The basic idea:
1) Remove all zones from a country, except one (in Configuration > International > Zones). Give the remaining zone the same name as the country (already proposed earlier in this thread).
2) Add the following behaviour to the views: When there is only one zone, select it automatically and hide the selector. Because of the auto-select, it will pass the required field checks. And because only the views are modified (ie: your browser behaviour), you can be pretty sure the zone stuff in the backend keeps working fine.
Step 1: Add a callback to the zone loading routines.
1) Find text /zone&country_id= in the files listed below
2) Every file has two matching lines. On both lines, replace the text '); with ', afterZoneLoad);
List of files that should be edited (from the /view/theme/default directory):
You should have 18 lines changed. Example of a single change:
Line before change:
Same line after change (look for text 'afterZoneLoad' at the end of the line):
Step 2: Add the callback function to /catalog/view/javascript/common.js:
1) Go to the end of the file and paste the following code:
Step 3: Double-wrap two odd zone selectors in a span tag to enable hiding:
1) Replace the following text in the files listed at the end of this step:
With this text (to just wrap it in <span><span>...</span></span>):
List of files that should be edited (from the /view/theme/default directory):
DISCLAIMER: Use at your own risk. I've tested it in a custom theme and wrote the manual for the default theme, so it may not be a perfect reflection of my changes. My solution does not run on a live site yet. But hey, it's free
1) Remove all zones from a country, except one (in Configuration > International > Zones). Give the remaining zone the same name as the country (already proposed earlier in this thread).
2) Add the following behaviour to the views: When there is only one zone, select it automatically and hide the selector. Because of the auto-select, it will pass the required field checks. And because only the views are modified (ie: your browser behaviour), you can be pretty sure the zone stuff in the backend keeps working fine.
Step 1: Add a callback to the zone loading routines.
1) Find text /zone&country_id= in the files listed below
2) Every file has two matching lines. On both lines, replace the text '); with ', afterZoneLoad);
List of files that should be edited (from the /view/theme/default directory):
- template\account\address_form.tpl
template\account\register.tpl
template\affiliate\edit.tpl
template\affiliate\register.tpl
template\checkout\address.tpl
template\checkout\guest.tpl
template\checkout\guest_shipping.tpl
template\checkout\register.tpl
template\total\shipping.tpl
You should have 18 lines changed. Example of a single change:
Line before change:
Code: Select all
<td><select name="country_id" onchange="$('select[name=\'zone_id\']').load('index.php? route=account/address/zone&country_id=' + this.value + '&zone_id=<?php echo $zone_id; ?>');">
Code: Select all
<td><select name="country_id" onchange="$('select[name=\'zone_id\']').load('index.php?route=account/address/zone&country_id=' + this.value + '&zone_id=<?php echo $zone_id; ?>', afterZoneLoad);">
1) Go to the end of the file and paste the following code:
Code: Select all
function afterZoneLoad() {
if ($('select[name=zone_id] option').size() == 2) {
$('select[name=zone_id] :nth-child(2)').attr('selected', 'selected')
$('select[name=zone_id]').parent().parent().css('display', 'none');
} else {
$('select[name=zone_id]').parent().parent().css('display', '');
}
}
1) Replace the following text in the files listed at the end of this step:
Code: Select all
<br />
<br />
<span class="required">*</span> <?php echo $entry_zone; ?><br />
<select name="zone_id" class="large-field">
</select>
Code: Select all
<span><span>
<br />
<br />
<span class="required">*</span> <?php echo $entry_zone; ?><br />
<select name="zone_id" class="large-field">
</select>
</span></span>
- template\checkout\guest.tpl
template\checkout\register.tpl
DISCLAIMER: Use at your own risk. I've tested it in a custom theme and wrote the manual for the default theme, so it may not be a perfect reflection of my changes. My solution does not run on a live site yet. But hey, it's free

THANK YOU!!! I've been trying for a very long time before finally finding your post. I'm going to need to remember this style="display:none;"Re: [1.5]Hide/remove/defult predefined Region/State
Postby andrixx » Thu Aug 11, 2011 10:26 pm
Hi again, I think I solved the problem, I just need to test it and edit all the template files.
I simply put
Code: Select all
style="display:none;"
inside the select tag for the Zone. And removed the text before it.
Original "Zone code" in template file:
Code: Select all
<div class="s_row_2 clearfix">
<label><?php echo $entry_zone; ?> *</label>
<select id="zone_id" name="zone_id" class="required"></select>
</div>
edited to:
Code: Select all
<div class="s_row_2 clearfix">
<select style="display:none;" id="zone_id" name="zone_id"></select>
</div>
I have seen other teplates/themes with the exact same codes for zones, so I hope this will help others... if it works!
Now, as a rookie on coding I pray this will work.

I tried your way but it wont work for me. When I selected guest at the checkout process it won't go to the next step. I bet its my custom theme thats messing with me.JonnyWee wrote:Here is a solution that works for all countries, with 1.5.1. The basic idea:
...
I returned to my old method but used the VQMOD file that Zippen made. With a bit tweak. As I said, I used a custom theme so I removed all the lines that are related to the theme .tpl fiels from the vqmod-file.
Then I edited my .tpl manually.
So for you who want to edit the core with the vqmod-file and manually change the template files of your custom theme. Here is what I did.
1. First add this modifed vqmod-file: 2. Grab the following template files:
- catalog/view/theme/YOURTHEME/template/checkout/guest.tpl
catalog/view/theme/YOURTHEME/template/checkout/guest_shipping.tpl
catalog/view/theme/YOURTHEME/template/checkout/register.tpl
catalog/view/theme/YOURTHEME/template/checkout/address.tpl
catalog/view/theme/YOURTHEME/template/account/register.tpl
catalog/view/theme/YOURTHEME/template/account/address_form.tpl
catalog/view/theme/YOURTHEME/template/total/shipping.tpl
Code: Select all
<div class="s_row_2 clearfix">
<label><?php echo $entry_zone; ?> *</label>
<select id="zone_id" name="zone_id" class="required"></select>
</div>
Code: Select all
style="display:none;"
Code: Select all
<div class="s_row_2 clearfix">
<select id="zone_id" name="zone_id" style="display:none;"></select>
</div>
That should be it.

I get the same error as Zippen. When I am at guest checkout it say "This field is required."
EDIT:
I changed back to the default theme and it worked. So it's theme related. Then I found the problem in:
view/theme/YOURTHEME/template/checkout/guest.tpl
where I before added there was a
so Zippen, I hope this one works for you too
EDIT:
I changed back to the default theme and it worked. So it's theme related. Then I found the problem in:
view/theme/YOURTHEME/template/checkout/guest.tpl
where I before added
Code: Select all
style="display:none;"
Code: Select all
class="required"

so Zippen, I hope this one works for you too

Thanks, this was very helpful. I have one small addition. The remove_region_state.xml of Zippen only worked for me (also for guest checkout) after I changed line 11 in this file to:
Probable cause (by deduction): because the 'zone_id' is not in the post, not having a 'zone_id' in the post-array will lead to an error further down the code of guest.php.
Code: Select all
<add><![CDATA[$this->request->post['zone_id'] = ''; /*if ($this->request->post['zone_id'] == '') {
Hi i am also struggling with this, so far i installed the VQmod of andrixx, and did Jaro's edit of line 11
Then i got to step 2 and realized my theme was quite different in coding so before i f**k too much up, I would appreciate if someone would take a glimpse at the coding ;-)
Should i still just
Add
Remove
Thanks alot in advance ;-)
Then i got to step 2 and realized my theme was quite different in coding so before i f**k too much up, I would appreciate if someone would take a glimpse at the coding ;-)
Code: Select all
<td><span class="required">*</span> <?php echo $entry_zone; ?></td>
<td><select name="zone_id" class="large-field">
</select></td>
</tr>
</table>
<br />
<div class="buttons">
<div class="right"><a id="button-guest-shipping" class="button"><span><?php echo $button_continue; ?></span></a></div>
</div>
<script type="text/javascript"><!--
$('#shipping-address select[name=\'zone_id\']').load('index.php?route=checkout/address/zone&country_id=<?php echo $country_id; ?>&zone_id=<?php echo $zone_id; ?>');
//--></script>
Add
Code: Select all
style="display:none;"
Code: Select all
class="required"
I am not sure but it looks like you still need to remove the code that makes the field required. And then also add the display none.
at this code (taken from your template)
try remove the first part and edit the rest so the whole part looks like this:
at this code (taken from your template)
Code: Select all
<td><span class="required">*</span> <?php echo $entry_zone; ?></td>
<td><select name="zone_id" class="large-field">
</select></td>
Code: Select all
<td><select style="display:none;" name="zone_id" class="large-field">
</select></td>
Who is online
Users browsing this forum: No registered users and 27 guests