Add Donation Amount Validation from EN for static and frequency-based validation - #342
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This feature expands the MinMaxAmount to allow for Min Amount, Max Amount and Error Messages to be provided to ENgrid directly from a Engaging Networks validator. This allows the client to change validators for their donation amount per page using EN validators instead of changing the ENgrid Options.
It also adds support for Engaging Network's new Donation Frequency based Donation Amount Validator.
All of this is added behind the feature flag UseAmountValidatorFromEN which has been set to false by default. Before deploying to clients, I advise checking they do not have any malfunctioning validators set - but this is unlikely since they would be causing a server-side error if they did.
The component searches the validators defined in
window.EngagingNetworks.validatorsfor one that is an AMNT (static amount) or FAMNT (frequency based amount) type and is also attached to the same component that we know to be the Donation Amount Input. Then, it either alters the MinMaxAmount configuration (if static) or sets up a Frequency Change listener to alter the configuration whenever the frequency changes. Logging has been added for when changes happen.Demo pages have been set up using this branch built on a branch of TNC's client theme https://github.com/4site-interactive-studios/engrid-tnc/tree/min-donation
Static donation amount - ENgrid has 5-50,000 and the page overrides it to 25-50,000 - https://preserve.nature.org/page/176342/donate/1?assets=min-donation&debug=log
Frequency based - there are different ranges for single, monthly, quarterly and annual (EN's validator does not support semi-annual) - https://preserve.nature.org/page/176334/donate/1?assets=min-donation&debug=log