Preload text tags for product attributes in variant related fields #6
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.
What
This changes the behavior of how text tags are rendered for product variant fields. Rather than load variant tags using AJAX on input, the tags are loaded as options and rendered on page load making them available when clicking on the field.
Why
I'm not sure if pre-rendering was previously considered but this solves two issues that I encountered.
Variants become unusable when the name of the attribute is shorter than 3 characters or is 3 characters and one is a non-alphanumeric character. An example is length such as 12"
image
The second field will not populate even if a correct value such as 12" is entered, it will blank on loss of focus.
Values such as 12", 20", 30", etc. could never be accessed when configuring variations for a product because the value of 10 is shorter than the 3 letter AJAX cutoff and (some? all?) non-alphanumeric characters are stripped for the AJAX request.
The second improvement that this brings is making is easier to use variants that have many options. I found myself forgetting the names of some the variants so I had to reference the configuration page. It's also possible to not be aware of all of the variants because the user may not be familiar with the shop, or has never seen the variants before. In the case of the lengths example, it would be easy to intend to add all lengths as variations but not typing all of the needed characters, i.e. typing 10", 12", 20", but forgetting or not being aware of 30" so those are never seen by the user.
What Changed
Pre-rendering the tags on page load, disabling AJAX in the InputfieldTextTags config for attribute options, and updating the method name to reflect the new behavior.
Additional Considerations
I'm not sure if this makes the AJAX endpoint located in PwCommerceHooks::hookFindPWCommerceProductAttributesOptions() unnecessary so that was kept as is.
Result