Skip empty options even when the SkipCheckRequiredOption flag is true #35608
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description (*)
A conditional is added to skip empty string options so that they are not included when adding a product to a quote.
Including empty string values will add an error to the quote item because
\Magento\Catalog\Model\Product\Option::getValueById
is unable to find a value for an empty string and therefore returns null, causing the else statement to be run in\Magento\Catalog\Model\Product\Option\Type\Select::getOptionSku
which adds an error to the listener:$this->getListener()->setHasError(true)->setMessage($this->_getWrongConfigurationMessage());
.This adds the
Some of the selected options are not currently available.
error in\Magento\Quote\Model\Quote\Item\AbstractItem::checkData
to itself.Fixed Issues (if relevant)
Manual testing scenarios (*)
Before the change:
An error message is shown
Some of the selected options are not currently available.
, forcing the user to use a workaround.The Submit Order button redirects the user to the same page with the error message, no order is created.
After the change:
No error message is displayed, order can be created as usual.
Questions or comments
My first PR here. I still need to figure out how tests work and whether I need to do any tests.
Contribution checklist (*)