break out into a separate form
This commit is contained in:
parent
8c58b66ec9
commit
fa75305d86
@ -104,23 +104,49 @@ function fulcrm_shoppingcart_buy_url( $product_id ) {
|
||||
return url( 'fulcrm/buy/' . $product_id . '/' . $hmac );
|
||||
}
|
||||
|
||||
function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $eventbookingtype, $product ) {
|
||||
$form = array();
|
||||
|
||||
$form[ 'title_event' ] = array( '#type' => 'markup',
|
||||
'#markup' => '<h1>' . check_plain( $eventbookingtype[ 'event' ][ 'name' ] ) . '</h1>',
|
||||
);
|
||||
$form[ 'title_eventbookingtype' ] = array( '#type' => 'markup',
|
||||
'#markup' => '<h2>' . check_plain( $eventbookingtype[ 'name' ] ) . '</h2>',
|
||||
);
|
||||
$form[ 'title_product' ] = array( '#type' => 'markup',
|
||||
'#markup' => '<h3>' . check_plain( $product[ 'name' ] ) . '</h3>',
|
||||
);
|
||||
|
||||
$form[ 'eventbookingtype' ] = array( '#type' => 'markup',
|
||||
'#markup' => '<pre>' . print_r( $eventbookingtype, 1 ) . '</pre>' );
|
||||
$form[ 'product' ] = array( '#type' => 'markup',
|
||||
'#markup' => '<pre>' . print_r( $product, 1 ) . '</pre>' );
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function fulcrm_shoppingcart_buy( $product_id, $hmac ) {
|
||||
$real_hmac = _fulcrm_shoppingcart_buy_hmac( $product_id );
|
||||
|
||||
if ( hash_equals( $real_hmac, $hmac ) ) {
|
||||
$api_data = fulcrm_apiv2_GET( 'product/' . $product_id . '/',
|
||||
$query = array( 'expand' => implode( ',', array( 'content_object',
|
||||
'selector_object',
|
||||
'person_ddatacollection',
|
||||
'organisation_ddatacollection',
|
||||
'thing_ddatacollection',
|
||||
'transaction_ddatacollection',
|
||||
'lineitem_ddatacollection',
|
||||
) ) ) );
|
||||
$product_data = fulcrm_apiv2_GET( 'product/' . $product_id . '/',
|
||||
$query = array( 'expand' => implode( ',', array( 'content_object',
|
||||
'selector_object',
|
||||
'person_ddatacollection',
|
||||
'organisation_ddatacollection',
|
||||
'thing_ddatacollection',
|
||||
'transaction_ddatacollection',
|
||||
'lineitem_ddatacollection',
|
||||
) ) ) );
|
||||
|
||||
if ( $api_data[ 'success' ] ) {
|
||||
switch ( fulcrm_apiv2_url_to_type( $api_data[ 'data' ][ 'content_object' ][ 'url' ] ) ) {
|
||||
if ( $product_data[ 'success' ] ) {
|
||||
switch ( fulcrm_apiv2_url_to_type( $product_data[ 'data' ][ 'content_object' ][ 'url' ] ) ) {
|
||||
case 'eventbookingtype':
|
||||
$eventbookingtype_data = fulcrm_apiv2_GET( $product_data[ 'data' ][ 'content_object' ][ 'url' ],
|
||||
$query = array( 'expand' => implode( ',', array( 'event' ) ) ) );
|
||||
if ( $eventbookingtype_data[ 'success' ] ) {
|
||||
return drupal_get_form( 'fulcrm_shoppingcart_buy_eventbookingtype_form', $eventbookingtype_data[ 'data' ], $product_data[ 'data' ] );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 'cannot handle these products yet';
|
||||
|
Loading…
x
Reference in New Issue
Block a user