|
|
|
@ -443,8 +443,8 @@ function _fulcrm_shoppingcart_buy_eventbookingtype_create_shoppingitem( &$form_s
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if ( $form_state[ 'fulcrm_shoppingcart' ][ 'eventbookingtype' ][ 'eventbooking_ddatacollection' ] ) {
|
|
|
|
|
$item[ 'd' ][ 'fulcrm' ][ 'eventbooking' ][ 'd' ][ 'fulcrm_collections' ] = array( $form_state[ 'fulcrm_shoppingcart' ][ 'eventbookingtype' ][ 'eventbooking_ddatacollection' ][ 's' ] );
|
|
|
|
|
$item[ 'd' ][ 'fulcrm' ][ 'eventbooking' ][ 'd' ][ '_structure' ] = $form_state[ 'fulcrm_shoppingcart' ][ 'eventbookingtype' ][ 'eventbooking_ddatacollection' ][ '_structure' ];
|
|
|
|
|
$item[ 'd' ][ 'fulcrm' ][ 'eventbooking' ][ '_drupal_gather' ][ '_structure' ] = $form_state[ 'fulcrm_shoppingcart' ][ 'eventbookingtype' ][ 'eventbooking_ddatacollection' ][ '_structure' ];
|
|
|
|
|
$item[ 'd' ][ 'fulcrm' ][ 'eventbooking' ][ '_drupal_gather' ][ 's' ] = $form_state[ 'fulcrm_shoppingcart' ][ 'eventbookingtype' ][ 'eventbooking_ddatacollection' ][ 's' ];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$api_data = fulcrm_apiv2_POST( 'shoppingitem/', $item, $query = array( 'expand' => 'd' ) );
|
|
|
|
@ -1229,27 +1229,7 @@ function fulcrm_shoppingcart_donate() {
|
|
|
|
|
return drupal_goto( 'fulcrm/checkout' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fulcrm_shoppingcart_pre_cart_step( &$cart ) {
|
|
|
|
|
die( 'DIE: ' . print_r( $cart, 1 ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fulcrm_shoppingcart_has_pre_cart_step( &$cart ) {
|
|
|
|
|
foreach ( $cart[ 'shoppingitems' ] as $k => $item ) {
|
|
|
|
|
if ( array_key_exists( 'eventbooking', $item[ 'd' ][ 'fulcrm' ] ) ) {
|
|
|
|
|
if ( array_key_exists( '_structure', $item[ 'd' ][ 'fulcrm' ][ 'eventbooking' ][ 'd' ] ) )
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fulcrm_shoppingcart_checkout() {
|
|
|
|
|
$cart = fulcrm_shoppingcart_get_session_cart( false );
|
|
|
|
|
if ( $cart && array_key_exists( 'url', $cart ) ) {
|
|
|
|
|
if ( fulcrm_shoppingcart_has_pre_cart_step( $cart ) ) {
|
|
|
|
|
return fulcrm_shoppingcart_pre_cart_step( $cart );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function _fulcrm_shoppingcart_checkout_2( &$cart ) {
|
|
|
|
|
$hook_results = module_invoke_all( 'fulcrm_shoppingcart_pre_cart_to_transaction', $cart );
|
|
|
|
|
foreach ( $hook_results as $hook_result )
|
|
|
|
|
return $hook_result;
|
|
|
|
@ -1283,6 +1263,87 @@ function fulcrm_shoppingcart_checkout() {
|
|
|
|
|
}
|
|
|
|
|
return 'problem 2';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fulcrm_shoppingcart_pre_cart_step_form_submit( $form, &$form_state ) {
|
|
|
|
|
$cart = $form_state[ 'fulcrm_shoppingcart' ][ 'cart' ];
|
|
|
|
|
foreach ( $cart[ 'shoppingitems' ] as $index => $item ) {
|
|
|
|
|
if ( array_key_exists( 'eventbooking', $item[ 'd' ][ 'fulcrm' ] ) ) {
|
|
|
|
|
if ( array_key_exists( '_drupal_gather', $item[ 'd' ][ 'fulcrm' ][ 'eventbooking' ] ) ) {
|
|
|
|
|
$item_no = 'shoppingitem' . $item[ 'id' ];
|
|
|
|
|
$item_d = fulcrm_collection_form_values_to_d( $item_no, $form_state[ 'values' ] );
|
|
|
|
|
foreach ( $item_d as $k => $v ) {
|
|
|
|
|
$form_state[ 'fulcrm_shoppingcart' ][ 'cart' ][ 'shoppingitems' ][ $index ][ 'd' ][ 'fulcrm' ][ 'eventbooking' ][ 'eventbooking' ][ $k ] = $v;
|
|
|
|
|
}
|
|
|
|
|
$api_data = fulcrm_apiv2_PATCH( $item[ 'url' ], array( 'd' => $form_state[ 'fulcrm_shoppingcart' ][ 'cart' ][ 'shoppingitems' ][ $index ][ 'd' ] ),
|
|
|
|
|
$query = array( 'expand' => implode( ',', array( 'd' ) ) ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fulcrm_shoppingcart_invalidate_cache();
|
|
|
|
|
return _fulcrm_shoppingcart_checkout_2( $cart );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fulcrm_shoppingcart_pre_cart_step_form( $form, &$form_state, $cart ) {
|
|
|
|
|
drupal_set_title( 'Additional Information Required' );
|
|
|
|
|
|
|
|
|
|
$form_state[ 'fulcrm_shoppingcart' ][ 'cart' ] = $cart;
|
|
|
|
|
// die( print_r( $cart,1 ) );
|
|
|
|
|
|
|
|
|
|
$form[ 'title_event' ] = array( '#type' => 'markup',
|
|
|
|
|
'#markup' => '<h1>Additional Information Required</h1>',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
foreach ( $cart[ 'shoppingitems' ] as $index => $item ) {
|
|
|
|
|
if ( array_key_exists( 'eventbooking', $item[ 'd' ][ 'fulcrm' ] ) ) {
|
|
|
|
|
if ( array_key_exists( '_drupal_gather', $item[ 'd' ][ 'fulcrm' ][ 'eventbooking' ] ) ) {
|
|
|
|
|
$item_no = 'shoppingitem' . $item[ 'id' ];
|
|
|
|
|
$form[ $item_no ] = array( '#type' => 'fieldset',
|
|
|
|
|
'#title' => $item[ 'd' ][ 'name' ],
|
|
|
|
|
);
|
|
|
|
|
$form[ $item_no ][ 'd' ] = fulcrm_collection_to_form( $item_no,
|
|
|
|
|
$item[ 'd' ][ 'fulcrm' ][ 'eventbooking' ][ '_drupal_gather' ],
|
|
|
|
|
$item[ 'd' ][ 'fulcrm' ][ 'eventbooking' ][ '_drupal_gather' ] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$form[ 'actions' ] = array( '#type' => 'actions' );
|
|
|
|
|
$form[ 'actions' ][ 'submit' ] = array( '#type' => 'submit',
|
|
|
|
|
'#value' => t('Submit'),
|
|
|
|
|
'#submit' => array( 'fulcrm_shoppingcart_pre_cart_step_form_submit' ),
|
|
|
|
|
);
|
|
|
|
|
return $form;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fulcrm_shoppingcart_pre_cart_step( &$cart ) {
|
|
|
|
|
return drupal_get_form( 'fulcrm_shoppingcart_pre_cart_step_form', $cart );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fulcrm_shoppingcart_has_pre_cart_step( &$cart ) {
|
|
|
|
|
foreach ( $cart[ 'shoppingitems' ] as $k => $item ) {
|
|
|
|
|
if ( array_key_exists( 'eventbooking', $item[ 'd' ][ 'fulcrm' ] ) ) {
|
|
|
|
|
if ( array_key_exists( '_drupal_gather', $item[ 'd' ][ 'fulcrm' ][ 'eventbooking' ] ) ) {
|
|
|
|
|
if ( array_key_exists( 'eventbooking', $item[ 'd' ][ 'fulcrm' ][ 'eventbooking' ] ) ) {
|
|
|
|
|
if ( empty( $item[ 'd' ][ 'fulcrm' ][ 'eventbooking' ][ 'eventbooking' ] ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fulcrm_shoppingcart_checkout() {
|
|
|
|
|
$cart = fulcrm_shoppingcart_get_session_cart( false );
|
|
|
|
|
if ( $cart && array_key_exists( 'url', $cart ) ) {
|
|
|
|
|
if ( fulcrm_shoppingcart_has_pre_cart_step( $cart ) ) {
|
|
|
|
|
return fulcrm_shoppingcart_pre_cart_step( $cart );
|
|
|
|
|
}
|
|
|
|
|
return _fulcrm_shoppingcart_checkout_2( $cart );
|
|
|
|
|
}
|
|
|
|
|
return 'problem 1';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|