Problem with state selection:
That problem goes that way:
Let's say u don't use a dropdown selection for state when customers create an account or u added this future after accounts where already created.
When u modify an order first on state field take the customer state . But if this state it isn't on the list when u update your order it takes the first state on the list not the state the customer put .
That is because
$update_customer_state = tep_get_zone_name($_POST['update_customer_country_id'],
$_POST['update_customer_zone_id'], $_POST['update_customer_state']);
<tr class="dataTableRow">
<td class="dataTableContent" valign="middle" align="right" nowrap><?php echo ENTRY_CITY_STATE; ?></td>
<td colspan="2" valign="top" class="dataTableContent" nowrap><input name="update_customer_city" size="15" value="<?php echo stripslashes($order->customer['city']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('customers_city', encodeURIComponent(this.value))"<?php } ?>>,</td>
<td valign="top" class="dataTableContent"><span id="customerStateMenu">
<?php if (ORDER_EDITOR_USE_AJAX == 'true') {
echo tep_draw_pull_down_menu('update_customer_zone_id',
tep_get_country_zones($order->customer['country_id']), $order->customer['zone_id'], 'style="width: 200px;" onChange="updateOrdersField(\'customers_state\', this.options[this.selectedIndex].text);"');
} else {
echo tep_draw_pull_down_menu('update_customer_zone_id',
tep_get_country_zones($order->customer['country_id']), $order->customer['zone_id'], 'style="width: 200px;"');
}?></span><span id="customerStateInput"><input name="update_customer_state" size="15" value="<?php echo stripslashes($order->customer['state']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('customers_state', encodeURIComponent(this.value))"<?php } ?>></span></td>
</tr>
There will always get the first state and when post will verify if state equal 1 and it is always true .
U need to make something like this:
$array_zones = tep_get_country_zones($order->customer['country_id']) ;
but in the select must be a default value: Something like Select a state : ... with id = - 1 .... so when u use post
$update_customer_state = tep_get_zone_name($_POST['update_customer_country_id'], $_POST['update_customer_zone_id'], $_POST['update_customer_state']);
If the customer state wasn't in the list of state the default value from the customer will be selected
Hope someone will implement this so everybody will understand.
A good day.
My solution:
<tr class="dataTableRow">
<td class="dataTableContent" valign="middle" align="right" nowrap><?php echo ENTRY_CITY_STATE; ?></td>
<td colspan="2" valign="top" class="dataTableContent" nowrap><input name="update_customer_city" size="15" value="<?php echo stripslashes($order->customer['city']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('customers_city', encodeURIComponent(this.value))"<?php } ?>>,</td>
<td valign="top" class="dataTableContent"><span id="customerStateMenu">
<?php if (ORDER_EDITOR_USE_AJAX == 'true') {
$zones_array = array();
$zones_query = tep_db_query("select zone_id, zone_name from " . TABLE_ZONES . " where zone_country_id = ". (int) $order->customer['country_id']. " order by zone_id");
$zones_array[0] = array('id' => '-1', 'text' => 'Select state');
while ($zones_values = tep_db_fetch_array($zones_query)) {
$zones_array[] = array('id' => $zones_values['zone_id'], 'text' => $zones_values['zone_name']);
}
echo tep_draw_pull_down_menu('update_customer_zone_id', $zones_array, $order->customer['zone_id'], 'style="width: 200px;" onChange="updateOrdersField(\'customers_state\', this.options[this.selectedIndex].text);"');
} else {
$zones_array = array();
$zones_query = tep_db_query("select zone_id, zone_name from " . TABLE_ZONES . " where zone_country_id = ". (int) $order->customer['country_id']. " order by zone_id");
$zones_array[0] = array('id' => '-1', 'text' => 'Select state');
while ($zones_values = tep_db_fetch_array($zones_query)) {
$zones_array[] = array('id' => $zones_values['zone_id'], 'text' => $zones_values['zone_name']);
}
echo tep_draw_pull_down_menu('update_customer_zone_id', $zones_array, $order->customer['zone_id'], 'style="width: 200px;"');
}?></span><span id="customerStateInput"><input name="update_customer_state" size="15" value="<?php echo stripslashes($order->customer['state']); ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onChange="updateOrdersField('customers_state', encodeURIComponent(this.value))"<?php } ?>></span></td>
</tr>
Edited by zipicip, 26 February 2010, 08:59.