Last active
December 2, 2022 16:56
-
-
Save omniacode/2514d3c84a80aa76e99234ff9c87d68e to your computer and use it in GitHub Desktop.
Formidable Forms - Limit Amount of Tickets that Can Be Purchased
This file contains 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
<?php | |
add_filter('frm_validate_field_entry', 'max_100_tickets', 10, 3); | |
function max_100_tickets( $errors, $posted_field, $posted_value ) { | |
$field_id = 249; // change this to the ID of the Quantity Field | |
$tickets_requested = $_POST['item_meta'][249]; //Change 249 to the field containing the number of tickets being requested | |
$remaining_tickets = $_POST['item_meta'][281]; //Change 281 to the calculated field containing the number of remaining tickets | |
if( $tickets_requested > $remaining_tickets ) { | |
$errors[ 'field' . $field_id ] = "You've requested more tickets than available. Please try again"; | |
} | |
return $errors; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment