implement forced-login for the case of experience 'force'

master
Marek Isalski 6 years ago
parent e243c3c99e
commit 00f7fb1465

@ -342,8 +342,39 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, &$form_sta
$form_state[ 'fulcrm_shoppingcart' ][ 'shoppingcart' ] = $cart;
}
function fulcrm_shoppingcart_buy_eventbookingtype_login_form_submit( $form, &$form_state ) {
user_login_submit( $form, $form_state );
$form_state[ 'redirect' ] = fulcrm_shoppingcart_buy_url( $form_state[ 'fulcrm_shoppingcart_redirect_buy_product_id' ] );
}
function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $person, $eventbookingtype, $product ) {
$form = array();
$person_id = NULL;
if ( array_key_exists( 'id', $person ) )
$person_id = $person[ 'id' ];
if ( is_null( $person_id ) ) {
switch ( variable_get( 'fulcrm_shoppingcart_experience', 'force' ) ) {
case 'guest':
break;
case 'user':
break;
case 'force':
if ( user_is_anonymous() ) {
drupal_set_message( t('You need to be logged in to continue shopping.'), 'error' );
$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 $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 $form;
}
break;
}
}
$event_id = $eventbookingtype[ 'event' ][ 'id' ];
$capacity = null;

Loading…
Cancel
Save