force individual bookings where there are options

master
Marek Isalski 6 years ago
parent 63a51abd24
commit eeb23bcfc9

@ -590,7 +590,7 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
$form[ '#submit' ] = 'fulcrm_shoppingcart_buy_eventbookingtype_person_add_guest_form_submit';
}
$form[ 'eventslots' ] = array( '#title' => 'Options',
$form[ 'eventslots' ] = array( '#title' => 'Choose Your Options',
'#type' => 'fieldset',
);
$eventslots = array();
@ -614,11 +614,13 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
$form[ 'eventslots' ][ $eventpart_id ][ '#options' ][ $eventslot_id ] = $eventslot[ 'name' ];
}
$choices = false;
foreach ( $form[ 'eventslots' ] as $eventpart_id => $eventpart ) {
if ( count( $eventpart[ '#options' ] ) == 1 ) {
foreach ( $eventpart[ '#options' ] as $option_key => $option_value )
$eventpart[ '#default_value' ] = $option_key;
} else {
$choices = true;
foreach ( $eventpart[ '#options' ] as $option_key => $option_value ) {
$eventslot_id = fulcrm_crypto_get_object_id_form_value( 'eventslot.id', $option_key );
if ( $eventslot_id && !fulcrm_shoppingcart_eventslot_has_capacity( $eventslot_id ) ) {
@ -628,6 +630,16 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
}
}
if ( $choices ) {
$form[ 'ticket_for_persons' ][ '#type' ] = 'radios';
if ( count( $form[ 'ticket_for_persons' ][ '#options' ] ) == 1 ) {
foreach ( $form[ 'ticket_for_persons' ][ '#options' ] as $option_key => $option_value )
$form[ 'ticket_for_persons' ][ '#default_value' ] = $option_key;
}
} else {
unset( $form[ 'eventslots' ] );
}
$form[ 'actions' ] = array( '#type' => 'actions' );
$form[ 'actions' ][ 'submit' ] = array( '#type' => 'submit',
'#value' => t('Add to Cart'),

Loading…
Cancel
Save