Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Now that we have profile reuse, we need to update the admin shipment form to use those values whenever an existing profile is selected. Currently the form validator only loads the address when using the address field inputs.
Comment | File | Size | Author |
---|---|---|---|
#22 | 3079228-22.patch | 6.31 KB | mglaman |
| |||
#20 | 3079228-20.patch | 5.48 KB | mglaman |
| |||
#18 | interdiff_16-18.txt | 1.11 KB | jsacksick |
#18 | 3079228-18.patch | 4.57 KB | jsacksick |
| |||
#7 | 3079228-7.patch | 4.36 KB | mglaman |
Comments
Comment #2
andyg5000Here's one approach to fixing the issue. Will need the Functional JS test to be updated.
Comment #3
mglamanGoing to work on a test for this today.
Comment #4
mglamanConfirmed. If you recalculate a shipment it sets the billing address to null.
Comment #5
mglamanThis does not account for editing the existing address
Comment #6
mglamanThis works for new or edited profiles. We need a test that has a shipping method that restricts a specific address component and modifies the address to prove it becomes valid or invalid.
Comment #7
mglamanAnd here's the test that verifies a shipping method with a Zone condition becomes available when the address is changed.
Comment #9
mglamanEnd of the day here, not sure why that failed. It passes locally, there must be something in my environment.
Comment #10
jsacksick CreditAttribution: jsacksick at Centarro commentedJust a reroll...
Comment #12
jsacksick CreditAttribution: jsacksick at Centarro commentedDebugging this...
Comment #13
jsacksick CreditAttribution: jsacksick at Centarro commentedOk... found this error:
The reason for that is that we're trying to load a profile with $selected_profile_id = '_original'.
Comment #14
jsacksick CreditAttribution: jsacksick at Centarro commentedOk, this time tests should be passing.
Instead of setting the address on the profile, I'm directly setting the profile on the shipment when available... This way, if custom fields other than the address are attached to a profile, and conditions are targeting them, the correct values should be used.
Comment #16
jsacksick CreditAttribution: jsacksick at Centarro commentedOk, so setting the shipment profile doesn't seem to be a good idea... The ValidReferenceConstraint returns a violation indicating that the profile cannot be referenced for some reason (This normally happens because of the access)...
So setting the address on the profile instead like in the previous patches...
Since $selected_profile_id could also contain "_new" and "_original", I'm now testing that $selected_profile_id is numeric.
Comment #18
jsacksick CreditAttribution: jsacksick at Centarro commentedHopefully the last attempt (Tests are passing locally)...
Comment #19
mglamanDiscussed with @jsacksick and the problem was
_original
for the selected profile ID.Comment #20
mglamanI cannot reproduce where _original exists, as the CustomerProfile form only lets it exist as a way to go back to an original entity. But this adds some safeguards. I also added a test to assert the first calculation accounts for the current profile. @jsacksick can reproduce, so this is definitely a safe bet to guard against.
Comment #21
mglamanOkay so @jsacksick and I did a call and determined there's something with chromedriver. It's skipping the first press of the recalculate button which sends
_original
.Comment #22
mglamanIt's due to manually clicking links, which doesn't wait for Drupal JavaScript behaviors to attach. So the first button press does nothing.
Comment #24
mglaman😱 fixed!