Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically hide/show and unrequire/require state fields based on country. #1050

Closed
Benunc opened this issue Sep 22, 2016 · 9 comments
Closed
Assignees
Milestone

Comments

@Benunc
Copy link
Member

Benunc commented Sep 22, 2016

Issue Overview

We currently populate the state/province dropdown with separate state lists, depending on the country. Would be nice to (especially in places like the UK and Germany where there is no "state") either populate that field with "n/a" or make it go away all together.

And it definitely needs to not be a required field if we don't have a case for it in the list at https://github.com/WordImpress/Give/blob/master/includes/country-functions.php#L60

@DevinWalker DevinWalker added this to the 1.9 milestone Oct 4, 2016
@DevinWalker DevinWalker modified the milestones: 1.9, 2.0 Apr 10, 2017
@DevinWalker DevinWalker modified the milestones: 1.8.10, 2.0 Jul 5, 2017
@DevinWalker
Copy link
Member

DevinWalker commented Jul 5, 2017

Good call @Benunc, let me add a bit here.

Further Description

  • 1: Please review how WooCommerce handles their state field changing per country. It is much like how I would like our address country and state fieldset to work when the donor changes countries. Note that we are using a different dropdown library than they are.

Functionality

When the donor changes the country field:

  1. If the country has states, display the state field - either as a text field or dropdown select if a list is available (like the US)
  2. If the country does not have states, remove the field, it's not necessary

Please correct the above if the functionality has been defined incorrectly.

Preview of Woo's Country Select Functionality:

2017-07-04_22-13-10


  • 2: Provide your recommendation on how we can achieve the optimal functionality above. Please also include what an analysis of what our current functionality is and the time it would take to improve it to the recommended functionality. Please also provide you analysis of what it would take to do unit tests to test this functionality?

  • 3: Develop the solution and submit a PR to the appropriate release branch set on this issue.

@raftaar1191
Copy link
Contributor

Working on the about issue

@raftaar1191
Copy link
Contributor

To Make the same that is being offered by WooCommerces we need to refactor the code.

  1. Recommendation on how we can achieve
    Need to make a list wherein country states are been added. If in the list country doest not find any states then no drop-down will not be shown and if it finds the states then there will be drop-down option show which will display the list of state that country has.

2.our current functionality
I have gone throughout our functionality we need to create some functions and need to depreciate the old one like the example: give_get_brazil_states_list which provided the list of states in Brazil and make all that thing into one array. Where in the key will be the country code and the value will be in array format containing the States pf the respected country.

  1. Time
    Around 10 hours.

raftaar1191 added a commit to raftaar1191/Give that referenced this issue Jul 11, 2017
Add new function and refactor some code
@DevinWalker DevinWalker modified the milestones: 1.8.11, 1.8.12 Jul 11, 2017
raftaar1191 added a commit to raftaar1191/Give that referenced this issue Jul 11, 2017
Change Place holder, Change JS condtion, Change ajax function
raftaar1191 added a commit to raftaar1191/Give that referenced this issue Jul 11, 2017
@raftaar1191
Copy link
Contributor

raftaar1191 commented Jul 11, 2017

Notes where to check for dropdown

  1. /wp-admin/edit.php?post_type=give_forms&page=give-donors&view=overview&id=3

  2. /wp-admin/edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=DONATION ID ( Backend donation single page )

  3. http://SITENAME/donations/first-form-all-fields-support-non-login-user-as-well/ ( Form single page frountend )

@DevinWalker
Copy link
Member

@raftaar1191 that sounds good. Let's proceed with the refactor.

raftaar1191 added a commit to raftaar1191/Give that referenced this issue Jul 12, 2017
Add condition to check if country has states in it
raftaar1191 added a commit to raftaar1191/Give that referenced this issue Jul 12, 2017
raftaar1191 added a commit to raftaar1191/Give that referenced this issue Jul 12, 2017
Fix JS issue for states in give form
@raftaar1191 raftaar1191 mentioned this issue Jul 12, 2017
3 tasks
@raftaar1191
Copy link
Contributor

@ravinderk
The above functionality is being added on the following PR please review and merge the PR
#1858

raftaar1191 added a commit to raftaar1191/Give that referenced this issue Jul 13, 2017
raftaar1191 added a commit to raftaar1191/Give that referenced this issue Jul 14, 2017
@DevinWalker DevinWalker reopened this Jul 17, 2017
@DevinWalker
Copy link
Member

DevinWalker commented Jul 17, 2017

@raftaar1191 I noticed an issue with this functionality which is why I'm reopening it.

Reopened Issue Description

If you notice how Woo works, the label above the state field changes from just "State" (for instance the USA), to "State / Country" and "Province" according to the country selected.

2017-07-17_16-07-11

2017-07-17_16-07-33

Our plugin should work exactly like this...

Right now the label is simply "State / Province / Country" which is not an optimal UX. This is confusing to people in the US who are used to simply seeing "State". Likewise for other countries.

Please fix and submit a new PR. Thanks

@raftaar1191
Copy link
Contributor

Working on the above issues

raftaar1191 added a commit to raftaar1191/Give that referenced this issue Jul 18, 2017
raftaar1191 added a commit to raftaar1191/Give that referenced this issue Jul 18, 2017
@raftaar1191
Copy link
Contributor

@DevinWalker @ravinderk

Here is the PR #1887 for the above issues

raftaar1191 added a commit to raftaar1191/Give that referenced this issue Jul 19, 2017
Fix when user disable the floting label for the form
raftaar1191 added a commit to raftaar1191/Give that referenced this issue Jul 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants