diff --git a/fulcrm_shoppingcart.module b/fulcrm_shoppingcart.module index 78b1ee8..ad9ad0c 100644 --- a/fulcrm_shoppingcart.module +++ b/fulcrm_shoppingcart.module @@ -466,10 +466,14 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe // $form[ 'person' ] = fulcrm_collection_to_form( 'person', $eventbookingtype[ 'person_ddatacollection' ], $person[ 'd' ] ); - if ( array_key_exists( 'name', $person ) ) - $persons = array( 'myself' => $person[ 'name' ] . ' (myself)' ); - else - $persons = array( 'myself' => '(myself)' ); + if ( array_key_exists( 'url', $person ) ) { + if ( array_key_exists( 'name', $person ) ) + $persons = array( 'myself' => $person[ 'name' ] . ' (myself)' ); + else + $persons = array( 'myself' => '(myself)' ); + } else { + $persons = array(); + } if ( array_key_exists( 'related_from_person2persons', $person ) ) { foreach ( $person[ 'related_from_person2persons' ] as $p2p ) { @@ -484,11 +488,21 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe } } - $form[ 'ticket_for_persons' ] = array( '#type' => 'checkboxes', - '#title' => 'Who is coming to the event? (add a new person to this list)', - '#description' => 'Tick the box next to each person for whom you want to buy a ticket.', - '#options' => $persons, - ); + if ( $persons ) { + $form[ 'ticket_for_persons' ] = array( '#type' => 'checkboxes', + '#title' => 'Who is coming to the event? (add a new person to this list)', + '#description' => 'Tick the box next to each person for whom you want to buy a ticket.', + '#options' => $persons, + ); + } else { + if ( $eventbookingtype[ 'person_ddatacollection' ] ) { + $collection_id = $eventbookingtype[ 'person_ddatacollection' ][ 'id' ]; + $collection_data = fulcrm_apiv2_GET( 'ddatacollection/' . $collection_id . '/' ); + if ( $collection_data[ 'success' ] ) { + $form[ 'new_person' ] = fulcrm_collection_to_form( 'person', $collection_data[ 'data' ], array() ); + } + } + } $form[ 'actions' ] = array( '#type' => 'actions' ); $form[ 'actions' ][ 'submit' ] = array( '#type' => 'submit', @@ -514,28 +528,24 @@ function fulcrm_shoppingcart_buy_eventbookingtype( $person, $eventbookingtype, $ $fulcrm_shoppingcart_buy_eventbookingtype_form = drupal_get_form( 'fulcrm_shoppingcart_buy_eventbookingtype_form', $person, $eventbookingtype, $product ); return theme( 'fulcrm_shoppingcart_buy_eventbookingtype', array( 'fulcrm_shoppingcart_buy_eventbookingtype_form' => $fulcrm_shoppingcart_buy_eventbookingtype_form, 'user_login_form' => $user_login_form ) ); - } else { - return 'ZZZ'; // drupal_render( something ); } break; case 'force': if ( user_is_anonymous() ) { - drupal_set_message( t('You need to be logged in to continue shopping.'), 'error' ); // XXX change to be on form + drupal_set_message( t('Sorry, but you need to be logged in to continue shopping.'), 'error' ); // XXX change to be on form $form = user_login( $form, $form_state ); $form_state[ 'fulcrm_shoppingcart' ][ 'redirect_buy_product_id' ] = $product[ 'id' ]; $form[ '#submit' ][] = 'fulcrm_shoppingcart_buy_eventbookingtype_login_form_submit'; - return 'XXX'; // drupal_render( $form ); + return drupal_render( $form ); } else { drupal_set_message( t('Sorry! There was a problem looking up your record, and this means we cannot complete this order.'), 'error' ); - return 'YYY'; // drupal_render( $form ); } break; } } - - - return drupal_get_form( 'fulcrm_shoppingcart_buy_eventbookingtype_form', $person_data[ 'data' ], $eventbookingtype_data[ 'data' ], $product_data[ 'data' ] ); + $form = drupal_get_form( 'fulcrm_shoppingcart_buy_eventbookingtype_form', $person, $eventbookingtype, $product ); + return druapl_render( $form ); } function fulcrm_shoppingcart_buy_generic_product_form_submit( $form, &$form_state ) { diff --git a/fulcrm_shoppingcart_buy_eventbookingtype.tpl.php b/fulcrm_shoppingcart_buy_eventbookingtype.tpl.php index 19d00fd..9123c35 100644 --- a/fulcrm_shoppingcart_buy_eventbookingtype.tpl.php +++ b/fulcrm_shoppingcart_buy_eventbookingtype.tpl.php @@ -15,7 +15,7 @@
-
+

Or continue your order by providing some details…