Preserve Remaining Count Conditional Logic Context
Limit Choices provides a useful feature for using the remaining count for a selected choice in conditional logic. Currently, this option does not preserve it’s context for the entire submission flow. For example, if there is one “spot” of a given choice remaining, the conditional logic on the frontend will evaluate with a remaining count of 1. However, on submission that spot is consumed and so the conditional logic will then evaluate with 0 remaining.
This stop-gap solution allows you to save the remaining count at the time of submission. You can then use this field to create conditional logic rules in post-submission contexts (i.e. Confirmations, Notifications, feeds).
Instructions
- Add a Hidden field to your form to capture the remaining count at the time of submission.
- Copy and paste this snippet into your theme’s functions.php file.
- Update the snippet per the inline instructions.
Code
Filename: gplc-preserve-remaining-context.php