'admin/store/settings/terms', 'title' => t('Terms & 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, */ function terms_details(){ $form = _terms(); $output = drupal_get_form('terms', $form); return $output; } // Actual settings form. function _terms(){ // Check and see if we're requiring terms, to set default value for form. $set = variable_get('ec_terms_and_conditions', ''); if (isset($set)) { $required = 'Y'; } else { $required = 'N'; } $form['terms']['switch'] = array( '#type' => 'select', '#title' => t('Present terms & conditions to user?'), '#options' => array('Y' => t('Yes'), 'N' => t('No')), '#default_value' => $required, ); $form['terms']['text'] = array( '#type' => 'textarea', '#title' => t('Your terms'), '#description' => t('These will be displayed during the checkout process. HTML Accepted'), '#cols' => 60, '#rows' => 15, '#default_value' => variable_get('ec_terms_and_conditions', ''), ); $form['save'] = array( '#type' => 'submit', '#value' => t('Save'), ); return $form; } function terms_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 some...'); } } function terms_submit($form_id, $form_values) { if($form_values['switch'] == 'Y'){ variable_set('ec_terms_and_conditions', $form_values['text']); drupal_set_message('Terms will be required during checkout'); } if($form_values['switch'] == 'N') { variable_del('ec_terms_and_conditions'); drupal_set_message('Terms will not be required during checkout'); } } /** * */ 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, $allowed_tags = array('a', 'em', 'strong', 'ul', 'ol', 'li', 'dl', 'dt', 'dd', 'div')); $form = _present_termsandconditions($terms); return $form; } break; case 'validate': if($txn->agree == '0') { form_set_error('error', 'Check the box below to accept these terms and conditions.'); } 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; } ?>