Post by matsrg » Wed Dec 02, 2009 3:59 pm

Hi!
I want to remove the zones in my opencart 1.3.4 because there is no need and use of it in Sweden.
How do I do that, please:-)

Mats

Newbie

Posts

Joined
Wed Dec 02, 2009 3:52 pm
Location - Uppsala, Sweden

Post by matsrg » Thu Dec 03, 2009 9:01 pm

An alternative could be setting zone not mandatory. Is that easier perhaps?

best regards,
Mats

Newbie

Posts

Joined
Wed Dec 02, 2009 3:52 pm
Location - Uppsala, Sweden

Post by yaxo » Fri Dec 04, 2009 3:42 am

I'm here looking for same solution, also from Sweden :) If you get any answers to this, could you publish the solution here too?

Newbie

Posts

Joined
Fri Dec 04, 2009 3:41 am

Post by matsrg » Fri Dec 04, 2009 5:24 am

Självklart delar jag med mig!
Sure I will tell you all :-X

Newbie

Posts

Joined
Wed Dec 02, 2009 3:52 pm
Location - Uppsala, Sweden

Post by dbstr » Fri Dec 04, 2009 6:01 am

Hi,

I'm actually working on a solution for this at the moment, as we dont need zones in Denmark either. But since all the shipping/payment/tax modules are all depending on a geozone, I was thinking about:

* Delete all the danish zones, and make a new one called 'Denmark' (for geozone purposes)

* If the selected country is 'Denmark', hide the zone selection (and auto-select the 'Denmark'-zone).

This way, I don't have to touch anything but the zone() methods, and add a few lines of javascript in a few files.

I would like to hear from Qphoria, as he seems to understand this stuff better than anyone.

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by dbstr » Fri Dec 04, 2009 7:51 am

A very quick fix:

As described in my previous post, you can remove all the sub-zones for Sweden, and make a new zone called 'Sweden' to not mess up your geo-zone modules (shipping/payment/tax)

When 'Sweden' is selected as country, the zone selection will disappear, but it will make sure the 'Sweden'-zone is chosen.

There are 4 files which requires modification, but it's the same changes to all of them.
-> controller/account/address.php
-> controller/account/create.php
-> controller/checkout/address.php
-> controller/checkout/guest.php
and the respective .tpl files

Note: '57' is country_id for Denmark. You will have to replace it with your id of Sweden. It's 203 by default.

Edit catalog/controller/account/create.php
Find (in function zone(), at the bottom)

Code: Select all

	    $output .= '<option value="FALSE">' . $this->language->get('text_select') . '</option>'; 
Replace with

Code: Select all

        $output = '';
        
        if($this->request->get['country_id'] != '57') {
		    $output .= '<option value="FALSE">' . $this->language->get('text_select') . '</option>';
        }
Edit catalog/view/theme/yourtemplate/template/account/create.tpl
Find:

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>
Replace with:

Code: Select all

          <tr id="zoneCheck">
            <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>
In the same file, at the bottom, find:

Code: Select all

$('select[name=\'zone_id\']').load('index.php?route=account/create/zone&country_id=<?php echo $country_id; ?>&zone_id=<?php echo $zone_id; ?>');
After, insert:

Code: Select all

$(document).ready(function () { 
    if ($("#country_id").attr('value') == '57') {
        $('#zoneCheck').css('display', 'none');
    }
    
    $("#country_id").change(function () {
        if(this.value == '57') {
            $('#zoneCheck').css('display', 'none'); 
        } else {
            $('#zoneCheck').css('display', '');
        }
    });
});
--
Edit: To get rid of the zone name @ invoices and stuff, enter this in the 'Address Format' field for your country:

Code: Select all

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

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by yaxo » Fri Dec 04, 2009 10:00 pm

Thank you! Works alright so far what I can see. Now I have other problems, but that's another thread

Newbie

Posts

Joined
Fri Dec 04, 2009 3:41 am

Post by matsrg » Mon Dec 07, 2009 11:51 pm

Thanks a lot!
It works great but I have a little question at the bottom of this page:
dbstr wrote:A very quick fix:

As described in my previous post, you can remove all the sub-zones for Sweden, and make a new zone called 'Sweden' to not mess up your geo-zone modules (shipping/payment/tax)

When 'Sweden' is selected as country, the zone selection will disappear, but it will make sure the 'Sweden'-zone is chosen.

There are 4 files which requires modification, but it's the same changes to all of them.
-> controller/account/address.php
-> controller/account/create.php
-> controller/checkout/address.php
-> controller/checkout/guest.php
and the respective .tpl files

Note: '57' is country_id for Denmark. You will have to replace it with your id of Sweden. It's 203 by default.

Edit catalog/controller/account/create.php
Find (in function zone(), at the bottom)

Code: Select all

	    $output .= '<option value="FALSE">' . $this->language->get('text_select') . '</option>'; 
Replace with

Code: Select all

        $output = '';
        
        if($this->request->get['country_id'] != '57') {
		    $output .= '<option value="FALSE">' . $this->language->get('text_select') . '</option>';
        }
Edit catalog/view/theme/yourtemplate/template/account/create.tpl
Find:

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>
Replace with:

Code: Select all

          <tr id="zoneCheck">
            <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>
In the same file, at the bottom, find:

Code: Select all

$('select[name=\'zone_id\']').load('index.php?route=account/create/zone&country_id=<?php echo $country_id; ?>&zone_id=<?php echo $zone_id; ?>');
After, insert:

Code: Select all

$(document).ready(function () { 
    if ($("#country_id").attr('value') == '57') {
        $('#zoneCheck').css('display', 'none');
    }
    
    $("#country_id").change(function () {
        if(this.value == '57') {
            $('#zoneCheck').css('display', 'none'); 
        } else {
            $('#zoneCheck').css('display', '');
        }
    });
});
--
Edit: To get rid of the zone name @ invoices and stuff, enter this in the 'Address Format' field for your country:

Code: Select all

{firstname} {lastname}
{company}
{address_1}
{address_2}
{postcode} {city}
{country}
[/color]

This last part I dont know where to find?
Best regards,
Mats

Newbie

Posts

Joined
Wed Dec 02, 2009 3:52 pm
Location - Uppsala, Sweden

Post by dbstr » Mon Dec 07, 2009 11:53 pm

Log in as admin -> Admin -> Configuration -> Localisation -> Country -> Find Sweden -> Edit :)

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by matsrg » Tue Dec 08, 2009 4:05 am

THANKS ::) ;) a lot!
Best regards,
Mats

Newbie

Posts

Joined
Wed Dec 02, 2009 3:52 pm
Location - Uppsala, Sweden

Post by pmchardy » Fri May 20, 2011 5:25 pm

Thanks for the above post. I would like to do this for all countries not just one, is this possible?


Thanks


Peter

Newbie

Posts

Joined
Fri May 20, 2011 4:56 am

Post by remiandre » Sun Dec 18, 2011 9:20 pm

Is this working on OpenCart 1.5.1.3.1?
Where can I find the country code for Norway?

Newbie

Posts

Joined
Sun Dec 18, 2011 1:10 am
Who is online

Users browsing this forum: Semrush [Bot] and 202 guests