Fix bug in admin interface where Bundle Option Is Required setting is not loaded. #3014
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 (*)
This fixes a bug in the admin area when editing Bundle Items Options on a Bundle type product. When "Is Required" on an Option is set to No, the select element on the screen is not initialized with the selected value from the database because of an oversight in the check for existence of a variable with value zero (in the case of Is Required = "No").
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
This happens because the javascript that initializes the "Is Required" select element only runs if the value is "Yes" (1) due to the code checking the value of the variable -- "No" (0) evaluates to false.
Note that the Is Required setting is saved correctly based on what currently shows in the Admin screen (Is Required will be set to Yes unless you change it before saving), and appears to be handled correctly in the customer view.
Questions or comments
I think that the intention of the code was to check for the existence of the variable, so I modified the check to look for whether the variable was defined using typeof.
I suspect this type of problem could show up in other places, but have not attempted to find other instances of this yet.
Contribution checklist (*)