If this is your first visit, check our documentation. To post, register or login.
Forums / Configuring the Zen Cart Admin / Managing Customers and Orders / How to make "State/Province" Drop/Down optional?

How to make "State/Province" Drop/Down optional?

Started by jack911 on 12 May 2020, 9:01 PM · Views: 2,033

Results 1 to 4 of 4
12 May 2020, 9:01 PM
#1
jack911 avatar

jack911

New Zenner

Join Date:
Nov 2006
Posts:
17
Plugin Contributions:
0

How to make "State/Province" Drop/Down optional?

I need to make State/Province field during registration optional (but not disabled/deleted/masked). I set:
Configurations - Minimum Values - State = BLANK (as in nothing, NOT"0")
Configurations - Customer Details - State = TRUE
Configurations - Customer Details - State - Always display as pulldown? = FALSE

Customers from countries that have no built-in states are able to create account with just Country chosen. But for those countries with built-in States/Provinces (i.e. USA, Australia), if customer doesn't select a state/province, an error comes back as

[##############################]Please select a state from the States pull down menu.
[/COLOR]
In other words, it forces customers from countries with built-in States/Provinces to select a State/Province

I read this post but didn't find answer..
https://www.zen-cart.com/showthread.php?79491-How-can-I-Make-certain-Customer-Registration-fields-optional

I have tried both Classic template, Westminister New template.

Someone help!

14 May 2020, 4:14 PM
#2
jack911 avatar

jack911

New Zenner

Join Date:
Nov 2006
Posts:
17
Plugin Contributions:
0

Re: How to make "State/Province" Drop/Down optional?

No one knows? COme on,.. please

6 Aug 2020, 6:36 AM
#3
fisher1 avatar

fisher1

New Zenner

Join Date:
Aug 2020
Posts:
6
Plugin Contributions:
0

Re: How to make "State/Province" Drop/Down optional?

Have you been able to deal with that question? What configuration parameters should I set?

6 Aug 2020, 12:15 PM
#4
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: How to make "State/Province" Drop/Down optional?

Yes, try this new module for Zen Cart 1.56c...

Twitch Make State Optional
20a for Zen Cart 1.56c - Twitch Base6
August 6.2020

Please backup your database and fileset locally prior to making changes to your Zen Cart shop.

This will install a switch in Admin > Configuration > Customer Details > Twitch - Make State Optional that controls the form check - messageStack and javascript - to allow the state to become optional during account creation.

Be sure to test on create account, login and split login as your site may handle these sign up methods differently.

Copyright (C) 2020 Twitchtoo Media

***** DEVELOPERS START *****

SQL Update
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Twitch - Make State Optional', 'TWI_ACCOUNT_STATE_OPTIONAL', 'false', '<br/>Make State <strong>Optional</strong> in Account Create Form?', '5', '7', 'zen_cfg_select_option(array('true', 'false'), ', now());

Uninstall Only
DELETE FROM configuration WHERE configuration_key in ('TWI_ACCOUNT_STATE_OPTIONAL');
Uninstall Only


Update template and core files...

includes/modules/YOUR_TEMPLATE/create_account.php
replace this:
$zone->MoveNext();
}
}

  if ($found_exact_iso_match) {
    $zone_id = $zone->fields['zone_id'];
    $zone_name = $zone->fields['zone_name'];
  } else {
    $error = true;
    $error_state_input = true;
    $messageStack->add('create_account', ENTRY_STATE_ERROR_SELECT);
  }
} else {
  if (strlen($state) < ENTRY_STATE_MIN_LENGTH) {
    $error = true;
    $error_state_input = true;
    $messageStack->add('create_account', ENTRY_STATE_ERROR);
  }
}

}

with this:
$zone->MoveNext();
}
}
if ($found_exact_iso_match) {
$zone_id = $zone->fields['zone_id'];
$zone_name = $zone->fields['zone_name'];
} else {
if (TWI_ACCOUNT_STATE_OPTIONAL == 'false') {
$error = true;
$error_state_input = true;
$messageStack->add('create_account', ENTRY_STATE_ERROR_SELECT);
} // eof TWI_ACCOUNT_STATE_OPTIONAL
}
} else {
if (strlen($state) < ENTRY_STATE_MIN_LENGTH) {
if (TWI_ACCOUNT_STATE_OPTIONAL == 'false') {
$error = true;
$error_state_input = true;
$messageStack->add('create_account', ENTRY_STATE_ERROR);
} // eof TWI_ACCOUNT_STATE_OPTIONAL
}
}
}

includes/form_check.js.php
replace this:

<?php if (ACCOUNT_STATE == 'true') { ?>

check_state(<?php echo (int)ENTRY_STATE_MIN_LENGTH . ', "' . ENTRY_STATE_ERROR . '", "' . ENTRY_STATE_ERROR_SELECT; ?>");

<?php } ?>

with this:

<?php if (ACCOUNT_STATE == 'true') { ?> <?php if (TWI_ACCOUNT_STATE_OPTIONAL == 'false') { ?>

check_state(<?php echo (int)ENTRY_STATE_MIN_LENGTH . ', "' . ENTRY_STATE_ERROR . '", "' . ENTRY_STATE_ERROR_SELECT; ?>");

<?php } ?> <?php } ?>

includes/modules/pages/create_account/jscript_form_check.php
replace this:

<?php if (ACCOUNT_STATE == 'true') { ?>

check_state(<?php echo (int)ENTRY_STATE_MIN_LENGTH . ', "' . ENTRY_STATE_ERROR . '", "' . ENTRY_STATE_ERROR_SELECT . '"'; ?>);

<?php } ?>

with this:

<?php if (ACCOUNT_STATE == 'true') { ?> <?php if (TWI_ACCOUNT_STATE_OPTIONAL == 'false') { ?>

check_state(<?php echo (int)ENTRY_STATE_MIN_LENGTH . ', "' . ENTRY_STATE_ERROR . '", "' . ENTRY_STATE_ERROR_SELECT . '"'; ?>);

<?php } ?> <?php } ?>

includes/modules/pages/login/jscript_form_check.php
replace this:

<?php if (ACCOUNT_STATE == 'true') { ?>

check_state(<?php echo (int)ENTRY_STATE_MIN_LENGTH . ', "' . ENTRY_STATE_ERROR . '", "' . ENTRY_STATE_ERROR_SELECT . '"'; ?>);

<?php } ?>

with this:

<?php if (ACCOUNT_STATE == 'true') { ?> <?php if (TWI_ACCOUNT_STATE_OPTIONAL == 'false') { ?>

check_state(<?php echo (int)ENTRY_STATE_MIN_LENGTH . ', "' . ENTRY_STATE_ERROR . '", "' . ENTRY_STATE_ERROR_SELECT . '"'; ?>);

<?php } ?> <?php } ?>

***** DEVELOPERS END *****

Twitch Make State Optional Complete!

***** Please Donate *****

If my work has helped you today in any way, show your appreciation with things like positive feedback or donations.
Find me at https://www.twitchtoo.com

Thanks

Twitch.

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian