- Issue created by @rhovland
- 🇺🇸United States rhovland Oregon
I've tracked this down to the following code block being removed.
https://git.drupalcode.org/project/commerce_shipping/-/commit/3f492dc441...If I restore that then the regression goes away.
- 🇺🇸United States rhovland Oregon
The issue is that for whatever reason $address is empty even where there is a shipping profile already attached to the shipment. This happens when the order is owned by anonymous. Oddly this does not happen when the order is owned by a user, even if they have no shipping addresses in their address book and it's only the address stored on the shipment.
This is also a problem if a shipping profile is attached to the shipment during building of the form (via custom code) and the address is blown away by the recalculate button regardless of ownership of the order.
- 🇺🇸United States rhovland Oregon
Here's a patch that "fixes" the problem by not touching the profile if the address is NULL.
The real fix will be figuring out why $address is empty and fixing that.
- First commit to issue fork.
- Merge request !18Issue #3350321: Recalculate shipping button blanks address when editing anon order shipments → (Merged) created by tbkot
- Status changed to Needs review
over 1 year ago 4:28pm 28 March 2023 - Status changed to Needs work
over 1 year ago 10:02am 29 March 2023 - 🇮🇱Israel jsacksick
@tBKoT: Please update an existing test, no need to define a new one, let's just expand ShipmentAdminTest. Besides, the tests-only patch doesn't seem to apply.
- Status changed to Needs review
over 1 year ago 7:50pm 29 March 2023 - 🇺🇸United States rhovland Oregon
After spending time in the debugger and testing different scenarios I'm pretty sure I know what is wrong and needs to be fixed.
Setting the selected_profile_id for anonymous users technically works but is the wrong approach here. We only need to trigger the code that updates the current shipment profile when the selected profile changes. Since an anonymous order will never have a choice of profiles to select there is no reason to update the profile.
What does need to happen is if the user clicks the edit button and changes the address. The shipment profile does need to be updated with the changes before rate recalculation or you won't see updated rates. This will not happen because that was what `if ($address !== NULL) {$shipment->getShippingProfile()->get('address')->setValue($address);}` was intended to do and invoking the profile selection path will wipe out those changes.
- Status changed to Active
over 1 year ago 6:19pm 30 March 2023 - 🇺🇸United States rhovland Oregon
Oops I left in some commented out code in that sample. This part needs to be removed
// If a new address is being entered, empty the shipment profile so no rates are returned. //elseif (!empty($selected_profile_id) && $selected_profile_id === '_new') { // $shipment->getShippingProfile()->set('address', NULL); //}
- last update
about 1 year ago 150 pass - last update
12 months ago Composer require failure - Status changed to Needs review
12 months ago 9:55am 30 November 2023 - last update
11 months ago 150 pass -
jsacksick →
committed c52ac18d on 8.x-2.x authored by
tBKoT →
Issue #3350321: Recalculate shipping button blanks address when editing...
-
jsacksick →
committed c52ac18d on 8.x-2.x authored by
tBKoT →
- Status changed to Fixed
11 months ago 11:23am 19 December 2023 Automatically closed - issue fixed for 2 weeks with no activity.