|
|
|
@ -329,7 +329,9 @@ function fulcrm_shoppingcart_person_add( $collection_id, $hmac ) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function _fulcrm_shoppingcart_buy_eventbookingtype_create_shoppingitem( &$form_state, $cart, $person_uuid, $person_name, $product_id ) {
|
|
|
|
|
function _fulcrm_shoppingcart_buy_eventbookingtype_create_shoppingitem( &$form_state, $cart, $person_uuid, $person_name, $product_id, $made_choices = array() ) {
|
|
|
|
|
$all_choices = array();
|
|
|
|
|
|
|
|
|
|
$shoppingitem_name = ( $form_state[ 'fulcrm_shoppingcart' ][ 'eventbookingtype' ][ 'event' ][ 'name' ] . "\r\n" .
|
|
|
|
|
$form_state[ 'fulcrm_shoppingcart' ][ 'eventbookingtype' ][ 'name' ] . ', ' . $person_name . "\r\n" .
|
|
|
|
|
$form_state[ 'fulcrm_shoppingcart' ][ 'product' ][ 'name' ] );
|
|
|
|
@ -340,16 +342,27 @@ function _fulcrm_shoppingcart_buy_eventbookingtype_create_shoppingitem( &$form_s
|
|
|
|
|
$eventpart_id = fulcrm_apiv2_url_to_pk( $eventbookingtypeslots[ 'eventslot' ][ 'eventpart' ] );
|
|
|
|
|
$eventslot_id = fulcrm_apiv2_url_to_pk( $eventbookingtypeslots[ 'eventslot' ][ 'url' ] );
|
|
|
|
|
|
|
|
|
|
if ( array_key_exists( $eventpart_id, $eventslotbookings ) )
|
|
|
|
|
drupal_set_message( 'XXX cannot yet cope with multiple choice event slot bookings; defaulting to first.', 'warning' );
|
|
|
|
|
if ( in_array( $eventpart_id, $made_choice ) ) {
|
|
|
|
|
$eventslotbookings[ $eventpart_id ] = $made_choice[ $eventpart_id ];
|
|
|
|
|
} else {
|
|
|
|
|
$eventslotbookings[ $eventpart_id ] = $eventslot_id;
|
|
|
|
|
|
|
|
|
|
$eventslotbookings[ $eventpart_id ] = $eventslot_id;
|
|
|
|
|
if ( !array_key_exists( $eventpart_id, $eventslotbookings ) )
|
|
|
|
|
$all_choices[ $eventpart_id ] = array();
|
|
|
|
|
$all_choices[ $eventpart_id ][] = $eventslot_id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
drupal_set_message( 'XXX no eventbookingtypeslots to choose from?', 'warning' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $person_uuid ) {
|
|
|
|
|
$additional_choices = array();
|
|
|
|
|
foreach ( $all_choices as $k => $v ) {
|
|
|
|
|
if ( count( $v ) > 1 )
|
|
|
|
|
$additional_choices[ $k ] = $v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $person_uuid && empty( $additional_choices ) ) {
|
|
|
|
|
$item = array( 'shoppingcart' => $cart[ 'url' ],
|
|
|
|
|
'product' => fulcrm_apiv2_make_url( 'product', $product_id ),
|
|
|
|
|
'quantity' => 1.0,
|
|
|
|
@ -375,7 +388,7 @@ function _fulcrm_shoppingcart_buy_eventbookingtype_create_shoppingitem( &$form_s
|
|
|
|
|
drupal_set_message( t('There was a problem adding your item to the shopping cart.'), 'error' );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $additional_choices;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, &$form_state ) {
|
|
|
|
@ -438,13 +451,17 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, &$form_sta
|
|
|
|
|
$add_person_name = $form_state[ 'fulcrm_shoppingcart' ][ 'persons' ][ $add_person_uuid ][ 'name' ];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_fulcrm_shoppingcart_buy_eventbookingtype_create_shoppingitem( $form_state, $cart,
|
|
|
|
|
$add_person_uuid, $add_person_name, $product_id );
|
|
|
|
|
$ac = _fulcrm_shoppingcart_buy_eventbookingtype_create_shoppingitem( $form_state, $cart,
|
|
|
|
|
$add_person_uuid, $add_person_name, $product_id );
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$person = $cart[ 'd' ][ 'fulcrm' ][ 'person' ][ $person_uuid ];
|
|
|
|
|
_fulcrm_shoppingcart_buy_eventbookingtype_create_shoppingitem( $form_state, $cart,
|
|
|
|
|
$person_uuid, $person[ 'name' ], $product_id );
|
|
|
|
|
$ac = _fulcrm_shoppingcart_buy_eventbookingtype_create_shoppingitem( $form_state, $cart,
|
|
|
|
|
$person_uuid, $person[ 'name' ], $product_id );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !empty( $ac ) ) {
|
|
|
|
|
drupal_set_message( t('Choices to make...'), 'warning' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|