From 1d7810da83a36aa3796cc3c83be78d43b6a9304f Mon Sep 17 00:00:00 2001 From: Marek Isalski Date: Wed, 17 Jun 2020 09:38:39 +0100 Subject: [PATCH] detect when there is an eventbooking ddatacollection to gather --- fulcrm_shoppingcart.module | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/fulcrm_shoppingcart.module b/fulcrm_shoppingcart.module index 09d160d..697f684 100644 --- a/fulcrm_shoppingcart.module +++ b/fulcrm_shoppingcart.module @@ -442,6 +442,11 @@ 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' ]; + } + $api_data = fulcrm_apiv2_POST( 'shoppingitem/', $item, $query = array( 'expand' => 'd' ) ); fulcrm_shoppingcart_invalidate_cache(); if ( $api_data[ 'success' ] ) { @@ -1224,9 +1229,27 @@ 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 ); + } + $hook_results = module_invoke_all( 'fulcrm_shoppingcart_pre_cart_to_transaction', $cart ); foreach ( $hook_results as $hook_result ) return $hook_result;