Page 1 of 1

Admin : Customer -> Form - Zone/Region : --None --

Posted: Tue Sep 16, 2014 10:16 am
by thegeekz
Hi,


REF: http://forum.opencart.com/viewtopic.php?f=20&t=129913

As my registration form in the front end (Social Login or Normal) -- all defaults to None for the Zone as Singapore has no states.


admin/view/template/sale/customer_form.tpl


It just seems that when Customer registered with -- None -- as the zone by default, what the Customer form in the back end will show :

Zone : -- Please select --

rather than -- None --

Any way to change that?

I'm based in Singapore so I need this function to work properly.

The code in question is this :

Code: Select all

                    <td><span class="required">*</span> <?php echo $entry_zone; ?></td>
           <td><select name="address[<?php echo $address_row; ?>][zone_id]">
                      </select>
                      <?php if (isset($error_address_zone[$address_row])) { ?>
                      <span class="error"><?php echo $error_address_zone[$address_row]; ?></span>
                      <?php } ?></td>

I tried replacing

Code: Select all

    <td><select name="address[<?php echo $address_row; ?>][zone_id]">
                      </select>

With what is in the Store Settings :

Code: Select all

                  <td><select name="config_zone_id">
                    </select></td>

Didn't solve the issue -- instead shows a empty dropdown box.

Please help ...

Thank you.

Regards

The Geekz


Edit :

Have tried the earlier thread @ General Support --- YUNO's reply, but it somehow didn't work: (do I have to register another customer and try -- maybe it doesn't apply to the already existing customer?)

try
open opencart1564\admin\view\template\sale\customer_form.tpl

line 420

Code: Select all

        html += '      <td><select name="address[' + address_row + '][zone_id]"><option value="false"><?php echo $this->language->get('text_none'); ?></option></select></td>';

replace to

Code: Select all

        html += '      <td><select name="address[' + address_row + '][zone_id]"><option value="false"><?php echo $this->language->get('text_select'); ?></option></select></td>';


Re: Admin : Customer -> Form - Zone/Region : --None --

Posted: Wed Sep 17, 2014 8:10 am
by IP_CAM
You could add a fixed Value into the Sections, where such Values are used, and DISPLAY IT TO HIDDEN,
meaning, the entire Field Section would not longer be visible either, but the matching value is beeing forwarded.
I have collected a few samples, it's possibly not complete, you have to check on other files and replace existing content by use of one or the other 'solution'!

I used the matching DB Numbers for Switzerland and the Canton of AARGAU set as default value.

Modifed registration code:

template/account/register.tpl

Code: Select all

 <tr>
<td style="display: none;">State</td>
<td style="display: none;"><input type="hidden" name="zone_id" value="3095">Alle</td>  
</tr>
<tr>
 <td style="display: none;">Country</span></td>
 <td style="display: none;"><input type="hidden" name="country_id" value="204">Schweiz</td>
 </tr> 
template/account/adress_form.tpl

Code: Select all

	 <tr>
 <td style="display: none;">State</td>
 <td style="display: none;"><input type="hidden" name="zone_id" value="3095">Alle</td>  
</tr>
<tr>
 <td style="display: none;">Country</span></td>
 <td style="display: none;"><input type="hidden" name="country_id" value="204">Schweiz</td>
 </tr> 
template/affiliate/edit.tpl

Code: Select all

            <span class="error"><?php echo $error_city; ?></span>
            <?php } ?></td>
        </tr>
				 <tr>
		<td style="display: none;">Kanton</td>
		<td style="display: none;"><input type="hidden" name="zone_id" value="3095">Alle</td>  
	</tr>
	<tr>
	<td style="display: none;">Land</span></td>
	<td style="display: none;"><input type="hidden" name="country_id" value="204">Schweiz</td>
	</tr> 
template/checkout/shipping_address.tpl

Code: Select all

      <td><span class="required">*</span> <?php echo $entry_city; ?></td>
      <td><input type="text" name="city" value="" class="large-field" /></td>
      </tr>
	  <td><select name="country_id" style="display: none;"><option value="204"></option></select></td><td><select name="zone_id" style="display: none;"><option value="3095"></option></select></td>  
	<tr>
template/checkout/payment_address.tpl

Code: Select all

    <tr>
      <td><span class="required">*</span> <?php echo $entry_city; ?></td>
      <td><input type="text" name="city" value="" class="large-field" /></td>
    </tr>
    <tr>
	  <td><select name="country_id" style="display: none;"><option value="204"></option></select></td><td><select name="zone_id" style="display: none;"><option value="3095"></option></select></td>  
    </tr>
template/affiliate/register.tpl

Code: Select all

           <span class="error"><?php echo $error_city; ?></span>
            <?php } ?></td>
        </tr>
		 <tr>
		<td style="display: none;">Kanton</td>
		<td style="display: none;"><input type="hidden" name="zone_id" value="3095">Alle</td>  
	</tr>
	<tr>
	<td style="display: none;">Land</span></td>
	<td style="display: none;"><input type="hidden" name="country_id" value="204">Schweiz</td>
	</tr> 
template/checkout/register.tpl

Code: Select all

     <span class="required">*</span> <?php echo $entry_city; ?><br />
<input type="text" name="city" value="" class="large-field" />
<br />
  <div style="display: none;">Kanton <input type="hidden" name="zone_id" value="3095">Alle</div>  
  <div style="display: none;">Land <input type="hidden" name="country_id" value="204">Schweiz</div>
  <br />

admin/template/sale/customer_form.tpl

---------------------------------------------------
about line 356-359:

Code: Select all

html += '>' + json['zone'][i]['name'] + '</option>';
}
} else {
html += '<option value="3095"><?php echo $text_none; ?></option>';
about line 356-359:

Code: Select all

html += '      <td><span class="required">*</span> <?php echo $entry_zone; ?></td>';
html += '      <td><select name="address[' + address_row + '][zone_id]"><option value="3095" selected><?php echo $this->language->get('text_none'); ?></option></select></td>';
html += '    </tr>';
Check also for other sections, i.E. Guest Shipments without registration, Admin User Account Edit, and so on...
and modify accordingly.

Samples:

Code: Select all

  
checkout/guest.tpl
-------------------------
  <br />
  <span class="required">*</span> <?php echo $entry_country; ?><br />
  <select name="country_id" class="large-field">
    <option value=""><?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>
  <br />
  <br />
  <span class="required">*</span> <?php echo $entry_zone; ?><br />
  <select name="zone_id" class="large-field">
  </select>
  <br />
---
checkout/guest_shipping.tpl
-------------------------------------
  <tr>
    <td><span class="required">*</span> <?php echo $entry_country; ?></td>
    <td><select name="country_id" class="large-field">
        <option value=""><?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></td>
  </tr>
  <tr>
    <td><span class="required">*</span> <?php echo $entry_zone; ?></td>
    <td><select name="zone_id" class="large-field">
      </select></td>
  </tr>
Test PIECE AFTER PIECE carefully, before adding another...

Good Luck
Ernie
openshop.li

Tip: You may later remove all unused Coutry/State DB-Lines from your MySql DB, it saves many hundred lines of unused DB-Content.

PS. KANTON means STATE
LAND means COUNTRY

Re: Admin : Customer -> Form - Zone/Region : --None --

Posted: Wed Sep 17, 2014 10:16 am
by thegeekz
Hi there,

Thanks for your reply.

Hmm, this is so confusing.

But I'm not sure, I just need the Admin -- Customer_form.tpl to be corrected I think, as other forms in the front end are working with -- None -- for Singapore as a default.

For Singapore, there's no states / region so the default id for this is "0", I think.

So are you saying that I should set it to "0" in all the tpl?


However, it will be a problem later if customer is from another country with a region / state.

Kindly clarify please?

Thank you.
IP_CAM wrote:You could add a fixed Value into the Sections, where such Values are used, and DISPLAY IT TO HIDDEN,
meaning, the entire Field Section would not longer be visible either, but the matching value is beeing forwarded.
I have collected a few samples, it's possibly not complete, you have to check on other files and replace existing content by use of one or the other 'solution'!

I used the matching DB Numbers for Switzerland and the Canton of AARGAU set as default value.

Modifed registration code:

template/account/register.tpl

Code: Select all

 <tr>
<td style="display: none;">State</td>
<td style="display: none;"><input type="hidden" name="zone_id" value="3095">Alle</td>  
</tr>
<tr>
 <td style="display: none;">Country</span></td>
 <td style="display: none;"><input type="hidden" name="country_id" value="204">Schweiz</td>
 </tr> 
template/account/adress_form.tpl

Code: Select all

	 <tr>
 <td style="display: none;">State</td>
 <td style="display: none;"><input type="hidden" name="zone_id" value="3095">Alle</td>  
</tr>
<tr>
 <td style="display: none;">Country</span></td>
 <td style="display: none;"><input type="hidden" name="country_id" value="204">Schweiz</td>
 </tr> 
template/affiliate/edit.tpl

Code: Select all

            <span class="error"><?php echo $error_city; ?></span>
            <?php } ?></td>
        </tr>
				 <tr>
		<td style="display: none;">Kanton</td>
		<td style="display: none;"><input type="hidden" name="zone_id" value="3095">Alle</td>  
	</tr>
	<tr>
	<td style="display: none;">Land</span></td>
	<td style="display: none;"><input type="hidden" name="country_id" value="204">Schweiz</td>
	</tr> 
template/checkout/shipping_address.tpl

Code: Select all

      <td><span class="required">*</span> <?php echo $entry_city; ?></td>
      <td><input type="text" name="city" value="" class="large-field" /></td>
      </tr>
	  <td><select name="country_id" style="display: none;"><option value="204"></option></select></td><td><select name="zone_id" style="display: none;"><option value="3095"></option></select></td>  
	<tr>
template/checkout/payment_address.tpl

Code: Select all

    <tr>
      <td><span class="required">*</span> <?php echo $entry_city; ?></td>
      <td><input type="text" name="city" value="" class="large-field" /></td>
    </tr>
    <tr>
	  <td><select name="country_id" style="display: none;"><option value="204"></option></select></td><td><select name="zone_id" style="display: none;"><option value="3095"></option></select></td>  
    </tr>
template/affiliate/register.tpl

Code: Select all

           <span class="error"><?php echo $error_city; ?></span>
            <?php } ?></td>
        </tr>
		 <tr>
		<td style="display: none;">Kanton</td>
		<td style="display: none;"><input type="hidden" name="zone_id" value="3095">Alle</td>  
	</tr>
	<tr>
	<td style="display: none;">Land</span></td>
	<td style="display: none;"><input type="hidden" name="country_id" value="204">Schweiz</td>
	</tr> 
template/checkout/register.tpl

Code: Select all

     <span class="required">*</span> <?php echo $entry_city; ?><br />
<input type="text" name="city" value="" class="large-field" />
<br />
  <div style="display: none;">Kanton <input type="hidden" name="zone_id" value="3095">Alle</div>  
  <div style="display: none;">Land <input type="hidden" name="country_id" value="204">Schweiz</div>
  <br />

admin/template/sale/customer_form.tpl

---------------------------------------------------
about line 356-359:

Code: Select all

html += '>' + json['zone'][i]['name'] + '</option>';
}
} else {
html += '<option value="3095"><?php echo $text_none; ?></option>';
about line 356-359:

Code: Select all

html += '      <td><span class="required">*</span> <?php echo $entry_zone; ?></td>';
html += '      <td><select name="address[' + address_row + '][zone_id]"><option value="3095" selected><?php echo $this->language->get('text_none'); ?></option></select></td>';
html += '    </tr>';
Check also for other sections, i.E. Guest Shipments without registration, Admin User Account Edit, and so on...
and modify accordingly.

Samples:

Code: Select all

  
checkout/guest.tpl
-------------------------
  <br />
  <span class="required">*</span> <?php echo $entry_country; ?><br />
  <select name="country_id" class="large-field">
    <option value=""><?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>
  <br />
  <br />
  <span class="required">*</span> <?php echo $entry_zone; ?><br />
  <select name="zone_id" class="large-field">
  </select>
  <br />
---
checkout/guest_shipping.tpl
-------------------------------------
  <tr>
    <td><span class="required">*</span> <?php echo $entry_country; ?></td>
    <td><select name="country_id" class="large-field">
        <option value=""><?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></td>
  </tr>
  <tr>
    <td><span class="required">*</span> <?php echo $entry_zone; ?></td>
    <td><select name="zone_id" class="large-field">
      </select></td>
  </tr>
Test PIECE AFTER PIECE carefully, before adding another...

Good Luck
Ernie
openshop.li

Tip: You may later remove all unused Coutry/State DB-Lines from your MySql DB, it saves many hundred lines of unused DB-Content.

PS. KANTON means STATE
LAND means COUNTRY

Re: Admin : Customer -> Form - Zone/Region : --None --

Posted: Thu Sep 25, 2014 9:58 am
by thegeekz
Any more further inputs?

Since I do think its just the Admin -- backend --- Customer Form needs help.

The rest are ok with --- None -- defaulting for Singapore as the country. (0 = Zone, since no Zone is defined for our country)