Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More comprehensive error messages for checkout validation #626

Merged
merged 1 commit into from
Jan 27, 2020

Conversation

mamazu
Copy link
Member

@mamazu mamazu commented Jan 22, 2020

Closes #574

@mamazu mamazu requested a review from a team as a code owner January 22, 2020 13:45
@mamazu mamazu changed the title Adding more comprehensive error messages for checkout More comprehensive error messages for checkout validation Jan 22, 2020

/** @var CartReadyForCheckout $constraint */
$validationMessage = $constraint->message;
switch ($cart->getState()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be more granular if we would just create 4 different validators?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but then you'd have to have control over in which order they are validated. It doesn't make sense to return a response like payment method not chosen if the cart hasn't been addressed yet. What we could do however is make multiple constraints that are validated by the same validator. Because the logic of the validator is always the same. I am not so sure however if that is a good idea.

@lchrusciel lchrusciel merged commit 83e1479 into Sylius:master Jan 27, 2020
@lchrusciel
Copy link
Member

Thanks, @mamazu! 🥇

@mamazu mamazu deleted the better_checkout_messages branch January 27, 2020 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

More verbose error messages on denied state changes during checkout
2 participants