now adding eventbooking data during booking process

master
Marek Isalski 5 years ago
parent 1d7810da83
commit 0f6b5be6e3

@ -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,15 +1229,108 @@ function fulcrm_shoppingcart_donate() {
return drupal_goto( 'fulcrm/checkout' );
}
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;
$transaction_data = fulcrm_apiv2_POST( $cart[ 'url' ] . 'transaction/', array(), array( 'expand' => implode( ',', array( 'd' ) ) ) );
fulcrm_shoppingcart_invalidate_cache();
if ( $transaction_data[ 'success' ] ) {
$hmac = fulcrm_crypto_object_id_hmac( 'transaction', $transaction_data[ 'data' ][ 'id' ] );
$transaction_push = array( 'd' => array( 'fulcrm_fund_transaction_pay_failure_url' => url( 'fulcrm/checkout/failure/' . $transaction_data[ 'data' ][ 'id' ]. '/' . $hmac, array( 'absolute' => TRUE ) ),
'fulcrm_fund_transaction_complete_success_url' => url( 'fulcrm/checkout/success/' . $transaction_data[ 'data' ][ 'id' ]. '/' . $hmac, array( 'absolute' => TRUE ) ),
'fulcrm_fund_transaction_complete_failure_url' => url( 'fulcrm/checkout/failure/' . $transaction_data[ 'data' ][ 'id' ]. '/' . $hmac, array( 'absolute' => TRUE ) ),
),
);
$transaction_data2 = fulcrm_apiv2_PATCH( $transaction_data[ 'data' ][ 'url' ],
$transaction_push, $query = array( 'expand' => implode( ',', array( 'd',
'lineitems',
'paymentitems',
) ) ) );
fulcrm_shoppingcart_invalidate_cache();
if ( $transaction_data2[ 'success' ] ) {
$hook_results = module_invoke_all( 'fulcrm_shoppingcart_post_cart_to_transaction', $transaction_data2[ 'data' ] );
foreach ( $hook_results as $hook_result )
return $hook_result;
return theme( 'fulcrm_shoppingcart_transaction_checkout', array( 'transaction' => $transaction_data2[ 'data' ],
'use_coupon_url' => fulcrm_shoppingcart_coupon_url( $transaction_data[ 'data' ][ 'id' ] ),
) );
}
return 'problem 3';
}
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 ) {
die( 'DIE: ' . print_r( $cart, 1 ) );
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( '_structure', $item[ 'd' ][ 'fulcrm' ][ 'eventbooking' ][ 'd' ] ) )
return true;
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;
@ -1249,39 +1342,7 @@ function fulcrm_shoppingcart_checkout() {
if ( fulcrm_shoppingcart_has_pre_cart_step( $cart ) ) {
return fulcrm_shoppingcart_pre_cart_step( $cart );
}
$hook_results = module_invoke_all( 'fulcrm_shoppingcart_pre_cart_to_transaction', $cart );
foreach ( $hook_results as $hook_result )
return $hook_result;
$transaction_data = fulcrm_apiv2_POST( $cart[ 'url' ] . 'transaction/', array(), array( 'expand' => implode( ',', array( 'd' ) ) ) );
fulcrm_shoppingcart_invalidate_cache();
if ( $transaction_data[ 'success' ] ) {
$hmac = fulcrm_crypto_object_id_hmac( 'transaction', $transaction_data[ 'data' ][ 'id' ] );
$transaction_push = array( 'd' => array( 'fulcrm_fund_transaction_pay_failure_url' => url( 'fulcrm/checkout/failure/' . $transaction_data[ 'data' ][ 'id' ]. '/' . $hmac, array( 'absolute' => TRUE ) ),
'fulcrm_fund_transaction_complete_success_url' => url( 'fulcrm/checkout/success/' . $transaction_data[ 'data' ][ 'id' ]. '/' . $hmac, array( 'absolute' => TRUE ) ),
'fulcrm_fund_transaction_complete_failure_url' => url( 'fulcrm/checkout/failure/' . $transaction_data[ 'data' ][ 'id' ]. '/' . $hmac, array( 'absolute' => TRUE ) ),
),
);
$transaction_data2 = fulcrm_apiv2_PATCH( $transaction_data[ 'data' ][ 'url' ],
$transaction_push, $query = array( 'expand' => implode( ',', array( 'd',
'lineitems',
'paymentitems',
) ) ) );
fulcrm_shoppingcart_invalidate_cache();
if ( $transaction_data2[ 'success' ] ) {
$hook_results = module_invoke_all( 'fulcrm_shoppingcart_post_cart_to_transaction', $transaction_data2[ 'data' ] );
foreach ( $hook_results as $hook_result )
return $hook_result;
return theme( 'fulcrm_shoppingcart_transaction_checkout', array( 'transaction' => $transaction_data2[ 'data' ],
'use_coupon_url' => fulcrm_shoppingcart_coupon_url( $transaction_data[ 'data' ][ 'id' ] ),
) );
}
return 'problem 3';
}
return 'problem 2';
return _fulcrm_shoppingcart_checkout_2( $cart );
}
return 'problem 1';
}

Loading…
Cancel
Save