You are here

function uc_termsofservice_checkout_pane_callback in Ubercart Terms of Service 6

Same name and namespace in other branches
  1. 7 uc_termsofservice.module \uc_termsofservice_checkout_pane_callback()

Callback form for checkout pane.

1 string reference to 'uc_termsofservice_checkout_pane_callback'
uc_termsofservice_checkout_pane in ./uc_termsofservice.module
Implements hook_checkout_pane().

File

./uc_termsofservice.module, line 164
Ubercart Terms of Service.

Code

function uc_termsofservice_checkout_pane_callback($op) {
  switch ($op) {
    case 'view':
      $show_tos = TRUE;

      // Check the conditional actions only if the user explicitly says to.
      if (variable_get('uc_termsofservice_checkout_ca', 0)) {
        $arguments = array(
          'cart' => array(
            '#entity' => 'cart',
            '#title' => t('Cart'),
            '#data' => uc_cart_get_contents(),
          ),
        );
        $predicates = ca_load_trigger_predicates('uc_termsofservice_display_pane');
        $predicate = $predicates['uc_termsofservice_display_pane'];
        if (!$predicate || !ca_evaluate_conditions($predicate, $arguments)) {
          $show_tos = FALSE;
        }
      }
      if ($show_tos) {
        if (module_exists('modalframe') && variable_get('uc_termsofservice_checkout_popup', 0)) {

          // If the modalframe module is enabled and the config for popups is
          // then the ToS is shown in a popup.
          modalframe_parent_js();
          drupal_add_js(drupal_get_path('module', 'uc_termsofservice') . '/uc_termsofservice.js');
          $node = uc_termsofservice_get_node('checkout');
          $width = variable_get('uc_termsofservice_checkout_popup_width', 500);
          $height = variable_get('uc_termsofservice_checkout_popup_height', 300);
          $form = uc_termsofservice_get_item('checkout', $node->title, 'uc_termsofservice/show/' . $node->nid, "{$width},{$height}");
        }
        else {
          $form = uc_termsofservice_general_form(array(), 'checkout');
        }
        return array(
          'contents' => $form,
        );
      }
      break;
    case 'settings':
      $form = uc_termsofservice_admin_form('checkout');
      return $form;
      break;
  }
}