You are here

function uc_checkout_pane_comments in Ubercart 7.3

Same name and namespace in other branches
  1. 5 uc_cart/uc_cart_checkout_pane.inc \uc_checkout_pane_comments()
  2. 6.2 uc_cart/uc_cart_checkout_pane.inc \uc_checkout_pane_comments()

Allows a customer to make comments on the order.

1 string reference to 'uc_checkout_pane_comments'
uc_cart_uc_checkout_pane in uc_cart/uc_cart.module
Implements hook_uc_checkout_pane().

File

uc_cart/uc_cart_checkout_pane.inc, line 330
Callbacks for the default Ubercart checkout panes plus helper functions.

Code

function uc_checkout_pane_comments($op, $order, $form = NULL, &$form_state = NULL) {
  switch ($op) {
    case 'view':
      $description = t('Use this area for special instructions or questions regarding your order.');
      if (!empty($order->order_id)) {
        $default = db_query("SELECT message FROM {uc_order_comments} WHERE order_id = :id", array(
          ':id' => $order->order_id,
        ))
          ->fetchField();
      }
      else {
        $default = NULL;
      }
      $contents['comments'] = array(
        '#type' => 'textarea',
        '#title' => t('Order comments'),
        '#default_value' => $default,
      );
      return array(
        'description' => $description,
        'contents' => $contents,
      );
    case 'process':
      db_delete('uc_order_comments')
        ->condition('order_id', $order->order_id)
        ->execute();
      if (strlen($form_state['values']['panes']['comments']['comments']) > 0) {
        uc_order_comment_save($order->order_id, 0, $form_state['values']['panes']['comments']['comments'], 'order', uc_order_state_default('post_checkout'), TRUE);
      }
      return TRUE;
    case 'review':
      $review = NULL;
      $result = db_query("SELECT message FROM {uc_order_comments} WHERE order_id = :id", array(
        ':id' => $order->order_id,
      ));
      if ($comment = $result
        ->fetchObject()) {
        $review[] = array(
          'title' => t('Comment'),
          'data' => check_plain($comment->message),
        );
      }
      return $review;
  }
}