'admin/store/settings/terms', 'title' => t('terms and conditions'), 'description' => t('Specify the Terms & Conditions that will be presented to a user during the checkout process.'), 'callback' => 'terms_details', 'access' => user_access('administer terms'), 'type' => MENU_NORMAL_ITEM, ); } return $items; } /** * Implementation of hook_perm(). */ function terms_perm() { return array('administer terms'); } /** * Build the settings page where the user can paste their Terms & Conditions, * as well as determine what type of display they'd like (scrolling div VS basic link) */ function terms_details() { $form = _terms(); $output = drupal_get_form('tandc', $form); return $output; } function _terms() { $form['terms']['switch'] = array( '#type' => 'select', '#title' => t('Present terms & conditions during checkout?'), '#options' => array('Y' => t('Yes'), 'N' => t('No')), '#default_value' => 'N', ); $form['terms']['text'] = array( '#type' => 'textarea', '#title' => t('Your terms'), '#description' => t('Enter the terms for your site here. Feel free to use HTML.'), '#cols' => 60, '#rows' => 15, '#default_value' => variable_get('ec_terms_and_conditions', ''), ); $form['save'] = array( '#type' => 'submit', '#value' => t('Save'), ); return $form; } function tandc_validate($form_id, $form_values) { if($form_values['switch'] == 'Y' && $form_values['text'] == ''){ form_set_error('error', 'If you\'re going to require terms you should probably enter something...'); } } function tandc_submit($form_id, $form_values) { if($form_values['switch'] == 'Y'){ variable_set('ec_terms_and_conditions', $form_values['text']); } if($form_values['switch'] == 'N') { drupal_set_message('Terms and Conditions will not be presented during checkout'); variable_del('ec_terms_and_conditions'); } drupal_set_message('Your settings have been saved.'); } /** * */ function terms_checkoutapi(&$txn, $op, $arg3 = NULL, $arg4 = NULL) { $output = ''; switch ($op) { case 'form': $require_terms = variable_get('ec_terms_and_conditions', ''); if($require_terms !== ''){ $terms = filter_xss($require_terms); $form = _present_termsandconditions($terms); return $form; } break; case 'validate': if($txn->agree == '0') { form_set_error('error', 'Check the box below to accept the refund policy.'); } break; case 'save': $txn->screen++; break; case 'review': break; case 'review_validate': break; case 'review_save': break; } } function _present_termsandconditions($terms) { $form['terms'] = array( '#type' => 'markup', '#value' => $terms, ); $form['agree'] = array( '#type' => 'checkbox', '#title' => t('I agree to these terms'), ); $form['continue'] = array( '#type' => 'submit', '#value' => t('Continue'), ); return $form; } ?>