You are here

function uc_checkout_pane_comments in Ubercart 6.2

Same name and namespace in other branches
  1. 5 uc_cart/uc_cart_checkout_pane.inc \uc_checkout_pane_comments()
  2. 7.3 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_checkout_pane in uc_cart/uc_cart.module
Implements hook_checkout_pane().

File

uc_cart/uc_cart_checkout_pane.inc, line 403
Callbacks for the default Ubercart checkout panes and their corresponding helper functions.

Code

function uc_checkout_pane_comments($op, &$arg1, $arg2) {
  switch ($op) {
    case 'view':
      $description = t('Use this area for special instructions or questions regarding your order.');
      if (!empty($arg1->order_id)) {
        $default = db_result(db_query("SELECT message FROM {uc_order_comments} WHERE order_id = %d", $arg1->order_id));
      }
      else {
        $default = NULL;
      }
      $contents['comments'] = array(
        '#type' => 'textarea',
        '#title' => t('Order comments'),
        '#default_value' => $default,
        '#wysiwyg' => FALSE,
      );
      return array(
        'description' => $description,
        'contents' => $contents,
      );
    case 'process':
      db_query("DELETE FROM {uc_order_comments} WHERE order_id = %d", $arg1->order_id);
      if (strlen($arg2['comments']) > 0) {
        uc_order_comment_save($arg1->order_id, 0, $arg2['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 = %d", $arg1->order_id);
      if ($comment = db_fetch_object($result)) {
        $review[] = array(
          'title' => t('Comment'),
          'data' => check_plain($comment->message),
        );
      }
      return $review;
  }
}