Close a webform when total seats reach a maximum I would like to know if it is possible to set-up a specific event registration webform to close automatically when the number of total reserved seats (reserved seats field) reaches a certain maximum. 

A little background: 
I have a few different event registration forms on my website, each event is held in a different venue with a maximum number of seats. The forms each have a reserved seats field, users can reserve up-to 2 seats(max) per submission. I cannot use the submission limit feature of the webform because the number of submissions do not map directly to the number of total seats that users are reserving. 

Is it possible to have the webform calculate the sum of the reserved seats field and close the form when it reaches a certain maximum number? How would I go about setting that up?
I built a custom handler to process seat reservations. I just wanted to share my code for anyone else looking to do the same thing. @jrockowitz let me know if you want to add this into webform core.    

&lt;?php
namespace Drupal\webform_reservations\Plugin\WebformHandler;


use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\webformSubmissionInterface;

/**
* Form submission handler.
*
* @WebformHandler(
* id = "webform_reservations_handler",
* label = @Translation("Reservations Handler"),
* category = @Translation("Form Handler"),
* description = @Translation("Manage maximum seat reservations"),
* cardinality = 
 \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_SINGLE,
* results = \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
* )
*/

class ReservationHandler extends WebformHandlerBase {


 /**
 * {@inheritdoc}
 */

  public function submitForm(array &amp;$form, FormStateInterface $form_state, 
  WebformSubmissionInterface $webform_submission) {
  $webform = $webform_submission-&gt;getWebform();
  $formid = $webform-&gt;id();

//query the db for all submissions of current webform submission
$query = \Drupal::entityQuery('webform_submission');
$query-&gt;condition('webform_id', $formid);
$result = $query-&gt;execute();

//load all the submissions from the results
$storage = \Drupal::entityTypeManager()-&gt;getStorage('webform_submission');
$submissions = $storage-&gt;loadMultiple($result);
$submission_data = array();


foreach ($submissions as $submission) {
$submission_data[] = $submission-&gt;getData();
}

$current_reserved = 0;

//add up all the values in the 'seats needed' field of each submission and save it to a variable.     
for ($i = 0; $i &lt; count($submission_data); $i++){
    $current_reserved += $submission_data[$i]['seats_needed'];
}

//when a registration form is submitted, check if the current reserved seats exceeds the value specifed in the maximum allowed seats field of the form.
if ($current_reserved &gt;= $webform-&gt;getElement('max_seats')['#value']) {
    $webform-&gt;setStatus('closed');
    $webform-&gt;save();

 $message = 'The form has ' . $current_reserved . ' reserved seats, the max seats is currently set to ' . $webform-&gt;getElement('max_seats')['#value'] .  ' the form will now be closed';        
  } else {$message = 'The form has ' . $current_reserved . ' reserved seats, the max seats is currently set to ' . $webform-&gt;getElement('max_seats')['#value'] .  ', the form will stay open';}        

//log the output to the drupal logger, to indicate if the webform is still open or closed after each submission.        
\Drupal::logger('webform_reservations')-&gt;info($message);    

}    
}
?&gt;