finally, it works

master
Marek Isalski 7 years ago
parent 29f6344509
commit 67215e6e7e

@ -289,8 +289,8 @@ function fulcrm_shoppingcart_person_add_guest_form_submit( $form, &$form_state )
if ( $api_data[ 'success' ] ) {
module_invoke_all( 'fulcrm_shoppingcart_person_add', $api_data[ 'data' ], array_key_exists( 'destination', $_GET ) ? $_GET[ 'destination' ] : variable_get( 'fulcrm_shoppingcart_proceed_url', url('<front>') ) );
$form_state[ 'fulcrm_collection' ][ 'person' ] = $person_data;
$form_state[ 'fulcrm_collection' ][ 'shoppingcart' ] = $api_data[ 'data' ];
$form_state[ 'fulcrm_shoppingcart' ][ 'person' ] = $person_data;
$form_state[ 'fulcrm_shoppingcart' ][ 'shoppingcart' ] = $api_data[ 'data' ];
} else {
drupal_set_message( t('There was a problem adding your item to the shopping cart.'), 'error' );
}
@ -364,7 +364,7 @@ function _fulcrm_shoppingcart_buy_eventbookingtype_create_shoppingitem( &$form_s
$api_data = fulcrm_apiv2_POST( 'shoppingitem/', $item, $query = array( 'expand' => 'd' ) );
fulcrm_shoppingcart_invalidate_cache();
if ( $api_data[ 'success' ] ) {
$hook_results = module_invoke_all( 'fulcrm_shoppingcart_post_add_to_cart', $cart, $person_data[ 'data' ], $api_data[ 'data' ] );
$hook_results = module_invoke_all( 'fulcrm_shoppingcart_post_add_to_cart', $cart, $api_data[ 'data' ] );
foreach ( $hook_results as $hook_result )
return $hook_result;
@ -387,13 +387,20 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, &$form_sta
if ( array_key_exists( 'uuid', $form_state[ 'fulcrm_shoppingcart' ][ 'person' ] ) )
$person_uuid = $form_state[ 'fulcrm_shoppingcart' ][ 'person' ][ 'uuid' ];
if ( array_key_exists( 'shoppingcart', $form_state[ 'fulcrm_shoppingcart' ] ) )
$cart = $form_state[ 'fulcrm_shoppingcart' ][ 'shoppingcart' ];
else
$cart = fulcrm_shoppingcart_get_session_cart();
$cart = fulcrm_shoppingcart_get_session_cart();
if ( $cart ) {
if ( !$person_uuid ) {
if ( array_key_exists( 'd', $cart ) &&
array_key_exists( 'fulcrm', $cart[ 'd' ] ) &&
array_key_exists( 'transaction', $cart[ 'd' ][ 'fulcrm' ] ) &&
array_key_exists( 'person', $cart[ 'd' ][ 'fulcrm' ][ 'transaction' ] )
) {
$person_uuid = $cart[ 'd' ][ 'fulcrm' ][ 'transaction' ][ 'person' ];
}
}
if ( $person_uuid ) {
$patch = FALSE;
if ( !array_key_exists( 'fulcrm', $cart[ 'd' ] ) ||
!array_key_exists( 'person', $cart[ 'd' ][ 'fulcrm' ] ) ||
!array_key_exists( $person_uuid, $cart[ 'd' ][ 'fulcrm' ][ 'person' ] ) ) {
@ -409,6 +416,11 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, &$form_sta
if ( $patch ) {
$api_data = fulcrm_apiv2_PATCH( $cart[ 'url' ], array( 'd' => $cart[ 'd' ] ),
$query = array( 'expand' => 'd' ) );
if ( $api_data[ 'success' ] ) {
$cart = $api_data[ 'data' ];
} else {
drupal_set_message( t('There was a problem adding your item to the shopping cart.'), 'error' );
}
fulcrm_shoppingcart_invalidate_cache();
}
}
@ -439,15 +451,14 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, &$form_sta
} else {
drupal_set_message( t('There was a problem adding your item to the shopping cart.'), 'error' );
}
$form_state[ 'fulcrm_shoppingcart' ][ 'shoppingcart' ] = $cart;
}
function fulcrm_shoppingcart_buy_eventbookingtype_person_add_guest_form_submit( $form, &$form_state ) {
fulcrm_shoppingcart_person_add_guest_form_submit( $form, $form_state );
if ( array_key_exists( 'person', $form_state[ 'fulcrm_shoppingcart' ] ) ) {
fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, $form_state );
// XXXXXX
} else {
drupal_set_message( t('There was a problem adding your item to the shopping cart.'), 'error' );
}
}
@ -609,10 +620,7 @@ function fulcrm_shoppingcart_buy_generic_product_form_submit( $form, &$form_stat
array_key_exists( 'uuid', $form_state[ 'fulcrm_shoppingcart' ][ 'person' ] ) )
$person_uuid = $form_state[ 'fulcrm_shoppingcart' ][ 'person' ][ 'uuid' ];
if ( array_key_exists( 'shoppingcart', $form_state[ 'fulcrm_shoppingcart' ] ) )
$cart = $form_state[ 'fulcrm_shoppingcart' ][ 'shoppingcart' ];
else
$cart = fulcrm_shoppingcart_get_session_cart();
$cart = fulcrm_shoppingcart_get_session_cart();
if ( is_array( $cart ) ) {
if ( $person_uuid ) {
@ -655,8 +663,6 @@ function fulcrm_shoppingcart_buy_generic_product_form_submit( $form, &$form_stat
} else {
drupal_set_message( t('There was a problem adding your item to the shopping cart.'), 'error' );
}
$form_state[ 'fulcrm_shoppingcart' ][ 'shoppingcart' ] = $cart;
}
function fulcrm_shoppingcart_buy_generic_product_form( $form, &$form_state, $person, $product ) {

Loading…
Cancel
Save