diff --git a/fulcrm_shoppingcart.module b/fulcrm_shoppingcart.module index 375d3e7..692070b 100644 --- a/fulcrm_shoppingcart.module +++ b/fulcrm_shoppingcart.module @@ -716,8 +716,11 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe } $choices = false; + $zero_options = false; foreach ( $form[ 'eventslots' ] as $eventpart_id => $eventpart_form ) { - if ( count( $eventpart_form[ '#options' ] ) == 1 ) { + if ( count( $eventpart_form[ '#options' ] ) == 0 ) { + $zero_options = true; + } else if ( count( $eventpart_form[ '#options' ] ) == 1 ) { foreach ( $eventpart_form[ '#options' ] as $option_key => $option_value ) $form[ 'eventslots' ][ $eventpart_id ][ '#default_value' ] = $option_key; } else { @@ -725,6 +728,10 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe } } + if ( $zero_options ) { + drupal_set_message(t('Unfortunately it looks like some of the choices for this type of ticket are completely sold out.'), 'error', FALSE); + } + if ( $choices ) { $form[ 'ticket_for_persons' ][ '#type' ] = 'radios'; if ( count( $form[ 'ticket_for_persons' ][ '#options' ] ) == 1 ) { @@ -752,6 +759,11 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe '#submit' => array( 'fulcrm_shoppingcart_buy_eventbookingtype_form_submit' ), ); + if ( $zero_options ) { + $form[ 'actions' ][ 'submit' ][ '#disabled' ] = true; + $form[ 'actions' ][ 'submit' ][ '#value' ] = t('Sold Out'); + } + return $form; }