When updating the address, the default value for the shipping method is not updated.
If the user doesn't manually select an option, submitting the form (with the previous default value) crashes
the review page.
How to replicate the issue:
- On the checkout review page, click to edit the shipping information.
- Change the address and make sure it corresponds to a different shipping method than the selected one (eg: change the country)
- Click on 'Recalculate shipping'
The shipping methods are updated successfully but there is no value selected by default.
- Click 'Continue to review' WITHOUT selecting a shipping method
This will create an error and will crash the website.
After some investigation, I realised that when the shipping is recalculated the default value is not updated and keeps the previous value submitted. Hence, when submitting the form the widget tries to access a value that doesn't exist anymore.
The method extractFormValues() is looking for a non defined index.
On the patch below, I implemented an afterBuild method on ShippingRateWidget that updates the default value and added a condition when calculating the default value.
Comment | File | Size | Author |
---|---|---|---|
#4 | fix_for_shipping_default_value_3102083.patch | 1.71 KB | andreastkdf |
Comments
Comment #2
andreastkdf CreditAttribution: andreastkdf commentedComment #3
andreastkdf CreditAttribution: andreastkdf commentedComment #4
andreastkdf CreditAttribution: andreastkdf commentedComment #5
andreastkdf CreditAttribution: andreastkdf commentedComment #6
jsacksick CreditAttribution: jsacksick at Centarro commentedThe patch no longer applies.
I tried reproducing the problem with the latest dev code, a default value is indeed not selected, but submitting the page doesn't actually crash, and the current shipping rate is correctly shown on the review page.
I'm wondering if we couldn't come up with a simpler fix (I'm sure we could find a way to fix this without the after build). I'm pretty sure this is caused by the fact that a rate is present in $form_state['input'], during AJAX operations).
Comment #7
jsacksick CreditAttribution: jsacksick at Centarro commentedMarking this as a duplicate of #3026546: User can select incorrect shipping option.