|
|
@ -16,6 +16,15 @@ function hook_fulcrm_shoppingcart_person_add( $person, $redirect_destination ) {
|
|
|
|
function hook_fulcrm_shoppingcart_pre_add_to_cart( $shoppingcart, $person, $product ) {
|
|
|
|
function hook_fulcrm_shoppingcart_pre_add_to_cart( $shoppingcart, $person, $product ) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function hook_fulcrm_shoppingcart_post_add_to_cart( $shoppingcart, $shoppingitem ) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function hook_fulcrm_shoppingcart_pre_remove_from_cart( $shoppingcart, $shoppingitem ) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function hook_fulcrm_shoppingcart_post_remove_from_cart( $shoppingcart, $product ) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function hook_fulcrm_shoppingcart_pre_cart_to_transaction( $shoppingcart ) {
|
|
|
|
function hook_fulcrm_shoppingcart_pre_cart_to_transaction( $shoppingcart ) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -312,6 +321,10 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, &$form_sta
|
|
|
|
|
|
|
|
|
|
|
|
$api_data = fulcrm_apiv2_POST( 'shoppingitem/', $item, $query = array( 'expand' => 'd' ) );
|
|
|
|
$api_data = fulcrm_apiv2_POST( 'shoppingitem/', $item, $query = array( 'expand' => 'd' ) );
|
|
|
|
if ( $api_data[ 'success' ] ) {
|
|
|
|
if ( $api_data[ 'success' ] ) {
|
|
|
|
|
|
|
|
$hook_results = module_invoke_all( 'fulcrm_shoppingcart_post_add_to_cart', $cart, $person_data[ 'data' ], $api_data[ 'data' ] );
|
|
|
|
|
|
|
|
foreach ( $hook_results as $hook_result )
|
|
|
|
|
|
|
|
return $hook_result;
|
|
|
|
|
|
|
|
|
|
|
|
drupal_set_message( t('Added "%item" to shopping cart.', array( '%item' => $item[ 'd' ][ 'name' ] ) ), 'status' );
|
|
|
|
drupal_set_message( t('Added "%item" to shopping cart.', array( '%item' => $item[ 'd' ][ 'name' ] ) ), 'status' );
|
|
|
|
$form_state[ 'redirect' ] = 'fulcrm/cart';
|
|
|
|
$form_state[ 'redirect' ] = 'fulcrm/cart';
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -366,6 +379,8 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
|
|
|
|
|
|
|
|
|
|
|
|
// $form[ 'person' ] = fulcrm_collection_to_form( 'person', $eventbookingtype[ 'person_ddatacollection' ], $person[ 'd' ] );
|
|
|
|
// $form[ 'person' ] = fulcrm_collection_to_form( 'person', $eventbookingtype[ 'person_ddatacollection' ], $person[ 'd' ] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
die( print_r( $person, 1 ) );
|
|
|
|
|
|
|
|
|
|
|
|
if ( array_key_exists( 'name', $person ) )
|
|
|
|
if ( array_key_exists( 'name', $person ) )
|
|
|
|
$persons = array( 'myself' => $person[ 'name' ] . ' (myself)' );
|
|
|
|
$persons = array( 'myself' => $person[ 'name' ] . ' (myself)' );
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -481,6 +496,10 @@ function fulcrm_shoppingcart_buy( $product_id, $hmac ) {
|
|
|
|
'transaction_ddatacollection',
|
|
|
|
'transaction_ddatacollection',
|
|
|
|
'lineitem_ddatacollection',
|
|
|
|
'lineitem_ddatacollection',
|
|
|
|
) ) ) );
|
|
|
|
) ) ) );
|
|
|
|
|
|
|
|
if ( !$product_data[ 'success' ] ) {
|
|
|
|
|
|
|
|
return 'error while fetching information about this product!';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( user_is_logged_in() )
|
|
|
|
if ( user_is_logged_in() )
|
|
|
|
$person_id = fulcrm_webhook_get_pk_for_entity_type( 'user', $user->uid, 'person' );
|
|
|
|
$person_id = fulcrm_webhook_get_pk_for_entity_type( 'user', $user->uid, 'person' );
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -502,19 +521,19 @@ function fulcrm_shoppingcart_buy( $product_id, $hmac ) {
|
|
|
|
return 'error while fetching your details!';
|
|
|
|
return 'error while fetching your details!';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$person_data = array( 'data' => array() );
|
|
|
|
$person_data = array( 'data' => array( 'uuid' => fulcrm_uuid_uuid4(),
|
|
|
|
|
|
|
|
'name' => 'website visitor',
|
|
|
|
|
|
|
|
'd' => array( 'name' => 'website visitor',
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( !$product_data[ 'success' ] ) {
|
|
|
|
$cart = fulcrm_shoppingcart_get_session_cart( $create = true );
|
|
|
|
|
|
|
|
if ( !$cart ) {
|
|
|
|
return 'error while fetching the contents of your shopping cart!';
|
|
|
|
return 'error while fetching the contents of your shopping cart!';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$shoppingcart_data = fulcrm_shoppingcart_get_session_cart( $create = true );
|
|
|
|
$hook_results = module_invoke_all( 'fulcrm_shoppingcart_pre_add_to_cart', $cart, $person_data[ 'data' ], $product_data[ 'data' ] );
|
|
|
|
if ( !$shoppingcart_data[ 'success' ] ) {
|
|
|
|
|
|
|
|
return 'error while fetching information about this product!';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$hook_results = module_invoke_all( 'fulcrm_shoppingcart_pre_add_to_cart', $shoppingcart_data[ 'data' ], $person_data[ 'data' ], $product_data[ 'data' ] );
|
|
|
|
|
|
|
|
foreach ( $hook_results as $hook_result )
|
|
|
|
foreach ( $hook_results as $hook_result )
|
|
|
|
return $hook_result;
|
|
|
|
return $hook_result;
|
|
|
|
|
|
|
|
|
|
|
@ -546,15 +565,32 @@ function fulcrm_shoppingcart_buy( $product_id, $hmac ) {
|
|
|
|
function fulcrm_shoppingcart_remove_shoppingitem_confirm_submit( $form, &$form_state ) {
|
|
|
|
function fulcrm_shoppingcart_remove_shoppingitem_confirm_submit( $form, &$form_state ) {
|
|
|
|
$api_data = fulcrm_apiv2_DELETE( $form_state[ 'fulcrm_shoppingcart' ][ 'shoppingitem' ][ 'url' ] );
|
|
|
|
$api_data = fulcrm_apiv2_DELETE( $form_state[ 'fulcrm_shoppingcart' ][ 'shoppingitem' ][ 'url' ] );
|
|
|
|
|
|
|
|
|
|
|
|
if ( $api_data[ 'success' ] )
|
|
|
|
if ( $api_data[ 'success' ] ) {
|
|
|
|
drupal_set_message( t('Removed "%item" from cart.', array( '%item' => ( array_key_exists( 'name', $form_state[ 'fulcrm_shoppingcart' ][ 'shoppingitem' ][ 'd' ] ) ? $form_state[ 'fulcrm_shoppingcart' ][ 'shoppingitem' ][ 'd' ][ 'name' ] : $form_state[ 'fulcrm_shoppingcart' ][ 'shoppingitem' ][ 'product' ][ 'name' ] ) ) ), 'status' );
|
|
|
|
drupal_set_message( t('Removed "%item" from cart.', array( '%item' => ( array_key_exists( 'name', $form_state[ 'fulcrm_shoppingcart' ][ 'shoppingitem' ][ 'd' ] ) ? $form_state[ 'fulcrm_shoppingcart' ][ 'shoppingitem' ][ 'd' ][ 'name' ] : $form_state[ 'fulcrm_shoppingcart' ][ 'shoppingitem' ][ 'product' ][ 'name' ] ) ) ), 'status' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$cart = fulcrm_shoppingcart_get_session_cart();
|
|
|
|
|
|
|
|
if ( !$cart ) {
|
|
|
|
|
|
|
|
return 'error while fetching information about your shopping cart!';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$hook_results = module_invoke_all( 'fulcrm_shoppingcart_post_remove_from_cart', $cart, $form_state[ 'fulcrm_shoppingcart' ][ 'shoppingitem' ][ 'product' ] );
|
|
|
|
|
|
|
|
foreach ( $hook_results as $hook_result )
|
|
|
|
|
|
|
|
return $hook_result;
|
|
|
|
|
|
|
|
}
|
|
|
|
$form_state[ 'redirect' ] = 'fulcrm/cart';
|
|
|
|
$form_state[ 'redirect' ] = 'fulcrm/cart';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function fulcrm_shoppingcart_remove_shoppingitem_confirm( $form, &$form_state, $shoppingitem ) {
|
|
|
|
function fulcrm_shoppingcart_remove_shoppingitem_confirm( $form, &$form_state, $shoppingitem ) {
|
|
|
|
$form_state[ 'fulcrm_shoppingcart' ][ 'shoppingitem' ] = $shoppingitem;
|
|
|
|
$form_state[ 'fulcrm_shoppingcart' ][ 'shoppingitem' ] = $shoppingitem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$cart = fulcrm_shoppingcart_get_session_cart();
|
|
|
|
|
|
|
|
if ( !$cart ) {
|
|
|
|
|
|
|
|
return 'error while fetching information about your shopping cart!';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$hook_results = module_invoke_all( 'fulcrm_shoppingcart_pre_remove_from_cart', $cart, $shoppingitem );
|
|
|
|
|
|
|
|
foreach ( $hook_results as $hook_result )
|
|
|
|
|
|
|
|
return $hook_result;
|
|
|
|
|
|
|
|
|
|
|
|
return confirm_form( $form,
|
|
|
|
return confirm_form( $form,
|
|
|
|
t('Remove from cart?'),
|
|
|
|
t('Remove from cart?'),
|
|
|
|
'fulcrm/cart',
|
|
|
|
'fulcrm/cart',
|
|
|
|