show if event is full
This commit is contained in:
parent
e750c7862b
commit
4e4c709c1a
@ -306,12 +306,33 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, &$form_sta
|
||||
}
|
||||
|
||||
function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $person, $eventbookingtype, $product ) {
|
||||
$form = array();
|
||||
$event_id = $eventbookingtype[ 'event' ][ 'id' ];
|
||||
|
||||
$capacity = null;
|
||||
$count = null;
|
||||
$api_data = fulcrm_apiv2_GET( 'event/' . $event_id . '/' );
|
||||
if ( $api_data[ 'success' ] )
|
||||
$capacity = $api_data[ 'data' ][ 'capacity' ];
|
||||
|
||||
$api_data = fulcrm_apiv2_GET( 'eventbooking/', $query = array( 'event' => $event_id,
|
||||
'confirmed__isnull' => 'False',
|
||||
'cancelled__isnull' => 'True',
|
||||
) );
|
||||
if ( $api_data[ 'success' ] )
|
||||
$count = $api_data[ 'data' ][ 'count' ];
|
||||
|
||||
if ( !is_null( $capacity ) && !is_null( $count ) ) {
|
||||
if ( $count >= $capacity ) {
|
||||
drupal_set_message( t('Sorry, this event must be sold out. There are no more tickets available.'), 'error' );
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
||||
$form_state[ 'fulcrm_shoppingcart' ][ 'person' ] = $person;
|
||||
$form_state[ 'fulcrm_shoppingcart' ][ 'eventbookingtype' ] = $eventbookingtype;
|
||||
$form_state[ 'fulcrm_shoppingcart' ][ 'product' ] = $product;
|
||||
|
||||
$form = array();
|
||||
|
||||
$form[ 'title_event' ] = array( '#type' => 'markup',
|
||||
'#markup' => '<h1>' . check_plain( $eventbookingtype[ 'event' ][ 'name' ] ) . '</h1>',
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user