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

Store Orders: Edit customer info on an order #18579

Merged
merged 9 commits into from
Oct 11, 2017

Conversation

ryelle
Copy link
Member

@ryelle ryelle commented Oct 5, 2017

This PR adds the ability to edit the customer info - name, email, phone, and address (billing and shipping) for an order. Once in the "edit" state on the single order screen, two edit buttons show up next to the labels:

addr-edit-state

These open modals, which are slightly different between billing/shipping – billing has phone and email, along with a "copy to shipping" checkbox

billing-modal
shipping-modal

The changes in the modals are saved in component state, and the redux state is only updated when "Save" is clicked. The reason for this is that we want to be able to discard address changes if the user clicks cancel, without accidentally discarding any other pending edits.

To test

This is still behind a feature flag, so you can review on development, but it won't be on staging or production once merged.

  • View an order, and click Edit Order to enter the edit state
  • Scroll down to the address, click the edit button next to billing
  • The billing modal should pop open, make some changes
  • Click copy to shipping, save
  • Your changes should update in both address displays
  • Click save, the order should update with new info

Test again with other combos of edits, without copy to shipping selected, just change shipping, cancel out of the modal, cancel out of the edit state, etc.

@ryelle ryelle added Store [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Oct 5, 2017
@ryelle ryelle self-assigned this Oct 5, 2017
@matticbot
Copy link
Contributor

@ryelle ryelle mentioned this pull request Oct 5, 2017
12 tasks
timmyc
timmyc previously requested changes Oct 5, 2017
Copy link
Contributor

@timmyc timmyc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments above ( of course one about proptypes - heh ) but looking really great! I did encounter one oddity while working with the forms.

If you edit the billing address twice, so click edit on billing - make no changes, close the dialog. Then open it backup again, the phone number is no longer displayed in the modal form. The number is still displayed on the order details screen, it just will not show in the form anymore.

Likewise if you edit billing first, then open shipping, then back to billing the phone number is missing. No changes made in this flow, but I believe the same happens if you do make a change.

The modal held up well in smaller viewports too - nice work.

I do wonder if the edit button itself next to the address fieldset labels looks a bit "heavy" from a design standpoint, maybe @jameskoster or @kellychoffman can chime in on that though.

last_name: PropTypes.string.isRequired,
phone: PropTypes.string,
} ),
closeDialog: PropTypes.func,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want updateAddress() here along with a default below?

import SectionHeader from 'components/section-header';

class OrderCustomerInfo extends Component {
static propTypes = {
orderId: PropTypes.number.isRequired,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, I know, me and my proptype comments 😆 isEditing, site, and siteId are now being passed in the connect - though looks like site isn't being used, only the id.

@jameskoster
Copy link
Contributor

@kellychoffman Let's chat about this. The edit -> edit flow feels weird to me.

@ryelle if we tweak that behaviour would you prefer we open a new issue?

@jameskoster
Copy link
Contributor

jameskoster commented Oct 6, 2017

Spoke with @kellychoffman decided to hold off on changing anything here until we've judged how the whole edit flow feels with the other actions implemented. As you were! xD

Going to tweak some styling bits and pieces now.

@kellychoffman
Copy link
Member

Yeah, I think the edit>edit flow only feels weird because its the only editable thing implemented right now. I think it will make more sense and feel fine once everything else is implemented. The original reason for having the editable customer info behind a button in a modal was to make the UI less overwhelming. I also don't think its the most common reason people edit orders.

@allendav
Copy link
Contributor

allendav commented Oct 6, 2017

Idea: use an email validator like

if ( ! emailValidator.validate( email ) ) {
does

@allendav
Copy link
Contributor

allendav commented Oct 6, 2017

I also suggest phone validation, but maybe in an advisory capacity only. It usually works well to flag malformed numbers, but I have seen it occasionally flag some valid numbers as invalid, e.g.

onValidate={ props.validateAccountRecoveryPhone }

@allendav
Copy link
Contributor

allendav commented Oct 6, 2017

Even though our merchants are presently restricted to be US or CA based, they might want to ship to customers in other countries, so we probably need to allow Country settings other than US and Canada. Probably need to handle State vs Province for those too (and some countries have neither)

screen shot 2017-10-06 at 4 02 47 pm

One particular example is the case of Puerto Rico, which WooCommerce for the last two years has treated as a country and not a state.

super( props );
this.state = {
address: props.address,
phoneCountry: 'US',
Copy link
Contributor

@allendav allendav Oct 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might I suggest here (and above, elsewhere) that the default country (edit: i.e. for new orders) be informed by the merchant's country. It would be better for Canadian merchants, for example, to see Canada as the default so they don't have to keep changing it.

You might even want to go ahead and use the merchant's state/province to pre-select that too.

Copy link
Contributor

@allendav allendav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done. I've made a few suggestions/recommendations, none of which are trivial. If you elect to do any of them, feel free to do so under separate PR(s). Tests well. Pre-approving.

@ryelle ryelle force-pushed the update/store-order-edit-customer branch from c2c769b to b58fec2 Compare October 9, 2017 21:16
@ryelle
Copy link
Member Author

ryelle commented Oct 9, 2017

@jameskoster Did you end up doing style tweaks? I think they got lost in one of my rebases 😟

@jameskoster
Copy link
Contributor

@jameskoster Did you end up doing style tweaks? I think they got lost in one of my rebases 😟

😟

It's fine, I just tweaked the edit buttons for addresses. I'll do it again.

@ryelle
Copy link
Member Author

ryelle commented Oct 10, 2017

@jameskoster Sorry, and thanks for bringing them back!

@timmyc The "edit billing twice and phone disappears" issue is fixed in #18680, and I've addressed your proptypes feedback :)

@allendav I'll do the email validation and state/country updates in a following PR, but I think the phone validation is overkill - this phone input gives some nice visual feedback in formatting the number when it's correctly entered, so if validation falsely flags some numbers it would be better to leave it out (IMO).

@timmyc timmyc dismissed their stale review October 11, 2017 15:50

Will review #18680 for the phone input fix - nice job tracking that down!

Copy link
Contributor

@timmyc timmyc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is testing out well for me now, also verified #18579 fixes the aforementioned issue here.

@ryelle ryelle added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Oct 11, 2017
@ryelle ryelle merged commit 1b359d5 into master Oct 11, 2017
@ryelle ryelle deleted the update/store-order-edit-customer branch October 11, 2017 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants