add block for donations

master
Marek Isalski 6 years ago
parent 268695c321
commit 73a03b77f5

@ -44,6 +44,44 @@ function hook_fulcrm_shoppingcart_transaction_success( $transaction ) {
function hook_fulcrm_shoppingcart_transaction_failure( $transaction ) { function hook_fulcrm_shoppingcart_transaction_failure( $transaction ) {
} }
function fulcrm_shoppingcart_block_info() {
$blocks[ 'donate' ] = array( 'info' => t('Make a Donation'),
'cache' => DRUPAL_CACHE_GLOBAL,
);
return $blocks;
}
function fulcrm_shoppingcart_block_view( $delta = '' ) {
$block = array();
if ( $delta == 'donate' ) {
if ( variable_get( 'fulcrm_shoppingcart_donations', false ) ) {
$solicited_product_id = variable_get( 'fulcrm_shoppingcart_donation_solicited_product', 0 );
if ( $solicited_product_id > 0 ) {
$person = array();
$product_data = fulcrm_apiv2_GET( 'product/' . $solicited_product_id . '/',
$query = array( 'expand' => implode( ',', array( 'content_object',
'selector_object',
'person_ddatacollection',
'organisation_ddatacollection',
'thing_ddatacollection',
'transaction_ddatacollection',
'lineitem_ddatacollection',
) ) ) );
$block[ 'subject' ] = t('Make a Donation');
if ( $product_data[ 'success' ] ) {
$block[ 'content' ] = drupal_get_form( 'fulcrm_shoppingcart_buy_donation_form', $person, $product_data[ 'data' ] );
} else {
$block[ 'content' ] = 'There was a problem loading the product to make a donation.';
}
}
}
}
return $block;
}
function fulcrm_shoppingcart_menu() { function fulcrm_shoppingcart_menu() {
/* /*
$items[ 'admin/config/services/fulcrm' ] = array( 'page callback' => 'system_admin_menu_block_page', $items[ 'admin/config/services/fulcrm' ] = array( 'page callback' => 'system_admin_menu_block_page',
@ -566,7 +604,7 @@ function _fulcrm_shoppingcart_buy_donation_product_update_form( &$form, &$form_s
'#title' => 'Donation', '#title' => 'Donation',
); );
$form[ 'donation' ][ 'donation_amount' ] = array( '#type' => 'textfield', $form[ 'donation' ][ 'donation_amount' ] = array( '#type' => 'textfield',
'#title' => 'Donation Amount (' . $product[ '_price' ][ 'currency' ] . ')', '#title' => 'Amount (' . $product[ '_price' ][ 'currency' ] . ')',
'#default_value' => sprintf( "%.2f", $product[ '_price' ][ 'item_net' ] ), '#default_value' => sprintf( "%.2f", $product[ '_price' ][ 'item_net' ] ),
); );
} }

Loading…
Cancel
Save