You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
7.4 KiB
PHP
122 lines
7.4 KiB
PHP
<?php
|
|
|
|
function fulcrm_shoppingcart_admin_form_submit( $form, &$form_state ) {
|
|
variable_set( 'fulcrm_shoppingcart_proceed_text', $form_state[ 'values' ][ 'proceed_text' ] );
|
|
variable_set( 'fulcrm_shoppingcart_proceed_url', $form_state[ 'values' ][ 'proceed_url' ] );
|
|
|
|
variable_set( 'fulcrm_shoppingcart_success_url', $form_state[ 'values' ][ 'success_url' ] );
|
|
variable_set( 'fulcrm_shoppingcart_failure_url', $form_state[ 'values' ][ 'failure_url' ] );
|
|
|
|
variable_set( 'fulcrm_shoppingcart_experience', $form_state[ 'values' ][ 'experience' ] );
|
|
variable_set( 'fulcrm_shoppingcart_event_itinerary', $form_state[ 'values' ][ 'event_itinerary' ] );
|
|
|
|
variable_set( 'fulcrm_shoppingcart_donations', $form_state[ 'values' ][ 'donation_enabled' ] );
|
|
variable_set( 'fulcrm_shoppingcart_donation_cart_product', intval( $form_state[ 'values' ][ 'donation_cart_product' ] ) );
|
|
variable_set( 'fulcrm_shoppingcart_donation_checkout_product', intval( $form_state[ 'values' ][ 'donation_checkout_product' ] ) );
|
|
variable_set( 'fulcrm_shoppingcart_donation_solicited_product', intval( $form_state[ 'values' ][ 'donation_solicited_product' ] ) );
|
|
|
|
drupal_set_message( t('Settings saved.'), 'status' );
|
|
}
|
|
|
|
function fulcrm_shoppingcart_admin_form( $form, &$form_state ) {
|
|
global $is_https;
|
|
|
|
$form[ 'title' ] = array( '#type' => 'item',
|
|
'#title' => 'fulcrm Shopping Cart Settings',
|
|
'#description' => '',
|
|
);
|
|
|
|
$form[ 'proceed_text' ] = array( '#type' => 'textfield',
|
|
'#title' => 'Link text to carry on shopping',
|
|
'#default_value' => variable_get( 'fulcrm_shoppingcart_proceed_text', 'Keep shopping' ),
|
|
);
|
|
$form[ 'proceed_url' ] = array( '#type' => 'textfield',
|
|
'#title' => 'URL to go to to carry on shopping',
|
|
'#default_value' => variable_get( 'fulcrm_shoppingcart_proceed_url', url( '<front>', array( 'absolute' => true ) ) ),
|
|
);
|
|
|
|
$form[ 'experience' ] = array( '#type' => 'select',
|
|
'#title' => t('Shopping Experience'),
|
|
'#options' => array( // 'nouser' => t('"Guest Checkout" as standard'), // XXX not today
|
|
'guest' => t('Allow Guests to "Checkout"'),
|
|
'user' => t('Must Login to "Checkout"'),
|
|
'force' => t('Must Login to "Add to Cart"'),
|
|
),
|
|
'#default_value' => variable_get( 'fulcrm_shoppingcart_experience', 'force' ),
|
|
);
|
|
|
|
$form[ 'event_itinerary' ] = array( '#type' => 'select',
|
|
'#title' => t('Event Itinerary'),
|
|
'#options' => array( 'elide' => t('Elide when no choices to make'),
|
|
'full' => t('Show in full'),
|
|
),
|
|
'#default_value' => variable_get( 'fulcrm_shoppingcart_event_itinerary', 'full' ),
|
|
);
|
|
|
|
$form[ 'fulcrm_url' ] = array( '#type' => 'fieldset',
|
|
'#title' => 'Return URLs',
|
|
);
|
|
|
|
$form[ 'fulcrm_url' ][ 'success_url' ] = array( '#type' => 'textfield',
|
|
'#title' => 'URL to return to upon transaction success',
|
|
'#default_value' => variable_get( 'fulcrm_shoppingcart_success_url', url( '<front>', array( 'absolute' => true ) ) ),
|
|
);
|
|
|
|
$form[ 'fulcrm_url' ][ 'failure_url' ] = array( '#type' => 'textfield',
|
|
'#title' => 'URL to return to upon transaction failure',
|
|
'#default_value' => variable_get( 'fulcrm_shoppingcart_failure_url', url( '<front>', array( 'absolute' => true ) ) ),
|
|
);
|
|
|
|
$products = array( '' => '-- disabled --' );
|
|
|
|
$product_data = fulcrm_apiv2_GET( 'product/',
|
|
$query = array( 'content_object__isnull' => 'true',
|
|
'page_size' => 1000,
|
|
) );
|
|
if ( $product_data[ 'success' ] ) {
|
|
if ( $product_data[ 'data' ][ 'results' ] ) {
|
|
foreach ( $product_data[ 'data' ][ 'results' ] as $product ) {
|
|
$products[ $product[ 'id' ] ] = $product[ 'name' ];
|
|
}
|
|
}
|
|
} else {
|
|
$products[ 'ERROR' ] = '** ERROR fetching products from fulcrm **';
|
|
}
|
|
|
|
$form[ 'donation' ] = array( '#type' => 'fieldset',
|
|
'#title' => 'Donations',
|
|
);
|
|
|
|
$form[ 'donation' ][ 'donation_enabled' ] = array( '#type' => 'checkbox',
|
|
'#title' => 'Donations enabled?',
|
|
'#default_value' => variable_get( 'fulcrm_shoppingcart_donations', false ),
|
|
);
|
|
$form[ 'donation' ][ 'donation_cart_product' ] = array( '#type' => 'select',
|
|
'#title' => 'Donation Product for "Add to Cart"',
|
|
'#default_value' => variable_get( 'fulcrm_shoppingcart_donation_cart_product', '' ),
|
|
'#options' => $products,
|
|
);
|
|
$form[ 'donation' ][ 'donation_checkout_product' ] = array( '#type' => 'select',
|
|
'#title' => 'Donation Product for Checkout',
|
|
'#default_value' => variable_get( 'fulcrm_shoppingcart_donation_checkout_product', '' ),
|
|
'#options' => $products,
|
|
);
|
|
$form[ 'donation' ][ 'donation_solicited_product' ] = array( '#type' => 'select',
|
|
'#title' => 'Donation Product for Donation Page',
|
|
'#default_value' => variable_get( 'fulcrm_shoppingcart_donation_solicited_product', '' ),
|
|
'#options' => $products,
|
|
);
|
|
|
|
$form[ 'actions' ] = array( '#type' => 'actions' );
|
|
$form[ 'actions' ][ 'save' ] = array( '#type' => 'submit',
|
|
'#value' => t('Save'),
|
|
'#submit' => array( 'fulcrm_shoppingcart_admin_form_submit' ),
|
|
);
|
|
|
|
return $form;
|
|
}
|
|
|
|
function fulcrm_shoppingcart_admin() {
|
|
return drupal_get_form( 'fulcrm_shoppingcart_admin_form' );
|
|
}
|