Improve state handling in address forms

Issue #105 resolved
Anonymous created an issue

The current handling of states in the checkout form is flawed - the form displays the an option menu of states for the default country, then provides no way to change the list or to type in a state. It also enforces entering a state for countries that do not need one.

The attached patch modifies this situation in the following ways:

  • It introduces a new settings property LOCAL_SALES_ONLY, which can be True for sites selling only in their default country (set using the COUNTRY_CODE property) or False for sites selling internationally.

  • When LOCAL_SALES_ONLY=True, the address form displays a menu with state options for the default country, if that country requires state input, or hides the state field if it does not. A state selection is enforced if the country requires a state selection. The country field is also hidden, and the default country value is entered into the address record.

  • When LOCAL_SALES_ONLY=False, the form displays a text field for state input. It then enforces the entry if the selected country requires a state, and allows state to be empty otherwise.

  • It creates a new module: satchmo.contact.common.py, in preparation for a future patch which will add a UI for registered customers to edit their address book entries.

Missing from this patch: JavaScript code (and supporting view) which will replace the state input field with a drop-down menu, and populate it on-the-fly using JSON when a new country is selected. I'm waiting for feedback on the current patch before writing the next one... in any case, this patch is fully useable as-is.

Reported by itai

Comments (3)

  1. Log in to comment