From eeb23bcfc90dd6a64d2c6e8eea7758c09399b164 Mon Sep 17 00:00:00 2001 From: Marek Isalski Date: Sun, 2 Sep 2018 15:27:47 +0100 Subject: [PATCH] force individual bookings where there are options --- fulcrm_shoppingcart.module | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/fulcrm_shoppingcart.module b/fulcrm_shoppingcart.module index 1b9c201..910eaf4 100644 --- a/fulcrm_shoppingcart.module +++ b/fulcrm_shoppingcart.module @@ -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'),