Closed (fixed)
Project:
Commerce Core
Version:
8.x-2.x-dev
Component:
Order
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
5 Jun 2019 at 14:09 UTC
Updated:
12 Sep 2019 at 12:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
bojanz commentedComment #3
mglamanI went with Addresses because it seems like Addressbook v Address book has different variance.
Amazon:
Your addresses (vs address book)
Payment options (vs payment method)
New Egg
My Address Book
Payment Options
Target
Addresses
Wallet
Best Buy
Addresses
Payment Methods
This was changed per some discussions w/ rszrama, but it still looks weird due to capitalization. Probably keep as Customer and add a display label to profile types?
See this @todo
Somewhere in here there needs to be access checks. Maybe not here but later on when we're processing each profile type?
Or we could make sure the route is compiled with allowed profile types and check access that way.
Use entity type manager to get storage properly. Lazy quick dev.
This fails because it was not updated to set to multiple, forgot to fix before upload.
Comment #4
mglamanHere are screenshots.
Comment #5
mglamanRerolled patch.
Comment #6
mglamanThere should only be one action, "Add address"
If one profile type, then show form. If more, show list of bundles. Like a typical addPage and addForm flow.
Remove @todo, we keep them here.
Comment #7
mglamanCheck point. Adds addPage and addForm concepts.
Comment #9
mglamanI need to add more CRUD tests for profiles. This just passes with basic interface navigation. It also needs manual testing. This has been just TDD thus far.
Comment #10
bojanz commentedWe should also rename classes that start with Addresses to AddressBook. It is confusing to have a plural class name, and we already have AddressBookSubscriber, and an address book as a code concept in general. The UI labels can stay "Addresses".
Comment #11
mglamanShoot I thought I had that in the comment.
Like this should be .address_book vs user_addresses and so forth.
@bojanz should I stuff all viable helpers (like loading valid profile types) into the AddressBookInterface? I didn't want to bloat it since it mostly works around managing individual profiles thus far.
Comment #12
mglamanUpdate. Renamed some things. Added a helper to get the valid profile types from the address book service.
Comment #13
mglamanThe immediate things that I can think of missing tests and reviews:
Clicking to add an address, one profile type. Submit form. Where do you end up?
Clicking to add an address, multiple types. Select type. Submit form. Where do you end up?
And then validating the addresses entered display.
I think the current profile entity form redirects you to the user canonical link. We'd want the addresses route.
Comment #14
mglamanNew patch. Profiles a profile form for address book that redirects to the address book after saving. Needs to test multiple profile types and adding. Also editing.
Comment #15
mglamanHere is an updated patch which adds access control checks.
Comment #16
lisastreeter commentedFirst tested with just the single 'customer' profile type and another non-commerce profile type on a plain install/Bartik theme. Everything looks good and is working smoothly for me.
Then updated the config for the second profile type to make it commerce_profile_type. That type was then properly combined into the main "Addresses" tab for the user. Both bundle types displayed as options for adding a new address, and I was taken back to addresses after submission. So still all good.
But...
Out of curiosity, I then tried setting my second profile type to not "Allow multiple profiles per user". (It only had one at the time.) My thinking is that you could want a single ("approved") billing address but multiple shipping addresses. When I did that, that section of addresses completely disappeared from my "Addresses". So it seems that the third party "commerce_profile_type" setting and the "Allow multiple profiles per user" settings are incompatible. I haven't had time yet to investigate why this is so.
Comment #17
bojanz commented#16 is a good point, we need to account for the "single" use case.
Also, our routes should use "address_book", not "addressbook", to match other code.
Comment #18
morbus iffI'd much prefer "address-book" to match the age-old "core prefers dashes for URLs" soft pattern.
@See
- admin/structure/display-modes
- admin/content/media-widget
- admin/content/media-widget-table
- etc.
- Default pathauto replacement character of -
(I might have misread you wrong; if the path of "addresses" isn't viable, I'd much rather see it be "address-book" instead of "address_book". If you're literally talking about route names vs. paths then, my mistake and sorry for the noise.)
Comment #19
bojanz commentedIt's about route names, the URLs are using "addresses" for now. We try to never use underscores in URLs.
Comment #20
mglamanWeird. This test asserts profiles owned by commerce which are single use falling back to the default profile UI.
Comment #21
mglamanI tried to reproduce #16 and cannot. HOWEVER
1. I used the Duplicate functionality to create my profile type
2. I had to run a cache rebuild for the local tasks to appear properly (profile problem, needs resolving and has been an age-old problem.)
Comment #22
rszrama commentedfyi, bojanz's on vacation but would love to see if Lisa can still apply the patch clean against dev (now that address book is initially committed) and report on if she can reproduce what she saw in #16. (Also, from a wordsmithing standpoint, I think we'll need to revert to "address book" b/c I had a real hard time coming up with sentences for various UI labels / descriptions in the checkout and admin screens without referring to an address "book" ... seemed easier to resolve the discrepancy by just sticking w/ the old school address book label for now.)
Comment #23
bojanz commentedI am certain Lisa's bug is legit because we don't consider "single" profile types to be Commerce profile types:
See the "multiple" condition, which shouldn't be there.
(And as a sidenote, that method needs to be called loadTypes(), to match loadAll() and loadDefault()).
Updating status for that and #22. I had a reroll in progress but it will need to wait until my first day back (thursday).
Comment #24
lisastreeter commentedCould not apply patch #15 on a clean site with commerce dev:
$ composer require 'drupal/commerce:2.x-dev'Given @bojanz's comment, I will wait on the reroll before trying again:
Comment #25
morbus iffI've marked #3068222: Customer profile display_label missing in shipped YAML as a duplicate of this one, but it does contain a one-line change that should probably be included in this one, for @bojanz's forthcoming reroll:
Comment #26
bojanz commentedThe part around customer profile types was the most unfinished (no profile type form checkbox, alters not modified to check for the flag, etc), so I've extracted that into a new issue which is now ready to land: #3072083: Allow any profile type to be used as a "customer" profile type.
The patch here will be rerolled once that happens. The goal of the reroll is to address the following problems:
1) We need to revert to the Address Book terminology in the UI, urls, code, as mentioned in #22.
2) The UI doesn't account for "single" profile types in any way. We need to show them in the address book tab, and we need to make sure they don't get add/delete/"set as default" links.
3) Since not every profile type is available on the "add" screen, the current single "Add address" link becomes confusing. We need to revert back to having an "Add address" link per profile type.
4) If the site has a single profile type, and that profile type is "single", we should hide the Address Book tab and allow the default profile UI to be used (tab with the profile type's display label). There is no point in having an address book for a single address.
5) The edit/delete/"set as default" operations currently use the default routes and forms, meaning that the customer is not redirected back to the Address book page, they're redirected to the user page instead. We need to provide our own routes/forms to fix that.
6) Now that we have our own operations, we need to make the listing use them. We need to either do a hook_entity_operations_alter() and swap them out if we detect the address book route, or replace the default profile view with our own view or twig-based listing. We used Twig for wishlist and it was quick and easy, so that's the plan here as well.
Comment #27
bojanz commentedThis addresses all points from #26, and works with the just released Profile 1.0. Should be close to final.
Comment #29
bojanz commentedImproved the CSS a bit and committed.
I'm really happy with the non-Views implementation of this UI. It's short and to the point.
People swapping out the controller, overriding the CSS, should have an easy time customizing things.
Plus, we've opened the door to future improvements (modals, etc).
I'd like to thank rszrama for bikeshedding the smaller details (empty texts, relation to add links) in the last minute, as aways.
Followups:
#3077908: Update the Address Book service for Profile 1.0
#3077935: [Address Book] Add a CSS class to the default profile in the user pages