lack of configurability on validation error messages

Created on 11 July 2024, 9 months ago

Problem/Motivation

The error message "A valid shipping method must be selected in order to check out." is hard coded, and not always clear to the user. In particular, if there's only one shipping method available (such as using Commerce UPS but only allowing, say, the UPS Ground option), meaning that the radio buttons are always hidden (since there's no choice to make), then entering an invalid address for which shipping cannot be calculated (say, a zip code that doesn't match the state, for which UPS will not be able to return a valid shipping quote) throws the above mentioned error. The implication is that the user needs to select a shipping method, but there is no such selection to be made - what the user really needs to do in this particular case is fix their address.

Steps to reproduce

Set up a shipping checkout flow where there's only one shipping method available (so the radio buttons never show), configured to auto-update calculations when the address is entered/changed, then enter an invalid address.

Proposed resolution

This probably opens up a whole nasty can of worms about how best to smooth out the validation and auto-updating behaviour for every possible configuration (and every possible crazy thing an end user could do in the address form for those configurations), but for now just being able to customize in the admin interface what error text will be displayed to the end user would be convenient. (In this case, knowing that the error might happen for more than one reason but was most likely due to an invalid address, one might change it to something like "Unable to calculate shipping. Please confirm that you have entered a valid address. If you continue to have difficulty, please contact us at (wherever).")

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Data model changes

TBD

Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇺🇸United States olarin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @olarin
  • 🇮🇱Israel jsacksick

    @Olarin: This would typically be handled by a hook_form_alter() or by swapping the shipping information pane.
    Not really sure it makes sense to expose a setting for that as it's relatively easy to alter, and I'm not even sure where the setting would belong... If we start by exposing this error message, then what about the other strings accross Shipping or Commerce core itself?

  • 🇺🇸United States olarin

    Fair point. I was looking at the OOP code and overthinking it and forgot about the good old standby option of a form_alter hook. Thanks for the reminder.

    On further reflection, rather than just closing this, I'll change this to a low priority bug report rather than a feature request, since given that the module hides the radio buttons in this particular use case, instructing the user to make a selection they can't make is unhelpful. (Come to think of it this situation might also occur if you had multiple shipping options but none of them were valid for the address you entered, either because it was an invalid address or simply not covered by the available options.) There's only so much Commerce Shipping can do at this level to know what went wrong (for instance it can't necessarily discern why a shipping provider didn't respond with a useful quote for a particular request), but it should be able to at least differentiate between "the user didn't select an option" and "we couldn't give the user any options to select" and attempt to provide some slightly more helpful guidance in the latter case.

  • 🇮🇱Israel jsacksick

    Good point! Feel free to drop a patch here, I'd be happy to review it and get it in :).

  • 🇺🇸United States olarin
  • 🇩🇪Germany Anybody Porta Westfalica

    @Olarin @jsacksick I think we fixed this in Use a theme function for rendering "there is no shipping rate" Needs review ?

    Close as duplicate?

  • 🇺🇸United States olarin

    Hm, I think so. That ticket made the text configurable, and also made the default text a little more generic, rather than assuming (perhaps incorrectly) what went wrong, so it addresses the biggest concerns of this ticket, preventing a reasonable configuration (only one shipping option enabled) from resulting in misleading errors out of the box. If there was more we could do to differentiate between different problems and make it possible to give more specific, helpful error messages, that would be nice, but as I alluded to previously that's probably not possible unless shipping providers give us additional data as to why they returned no valid shipping options ("I can't ship to that address via these methods" vs. "I don't recognize that as a valid address").

  • 🇺🇸United States olarin
Production build 0.71.5 2024