You are here

function uc_payment_method_other in Ubercart 5

Same name and namespace in other branches
  1. 6.2 payment/uc_payment_pack/uc_payment_pack.module \uc_payment_method_other()
  2. 7.3 payment/uc_payment_pack/uc_payment_pack.module \uc_payment_method_other()

Handle the generic payment method "Other."

1 string reference to 'uc_payment_method_other'
uc_payment_pack_payment_method in payment/uc_payment_pack/uc_payment_pack.module
Implementation of hook_payment_method().

File

payment/uc_payment_pack/uc_payment_pack.module, line 67
Provides the check/money order, COD, and "other" payment methods.

Code

function uc_payment_method_other($op, &$arg1) {
  switch ($op) {
    case 'order-view':
    case 'customer-view':
      $result = db_query("SELECT description FROM {uc_payment_other} WHERE " . "order_id = %d", $arg1->order_id);
      if ($row = db_fetch_object($result)) {
        $output = t('Type:') . ' ' . $row->description;
      }
      else {
        $output = t('Type:') . ' ' . t('Unknown');
      }
      return $output;
    case 'order-details':
      $details = drupal_get_form('uc_payment_method_other_form', $arg1);
      return uc_strip_form($details);
    case 'edit-process':
      $changes['payment_details']['pm_other_description'] = check_plain($_POST['pm_other_description']);
      return $changes;
    case 'order-load':
      $result = db_query("SELECT description FROM {uc_payment_other} WHERE " . "order_id = %d", $arg1->order_id);
      if ($row = db_fetch_object($result)) {
        $arg1->payment_details['description'] = $row->description;
      }
      break;
    case 'order-save':
      db_query("DELETE FROM {uc_payment_other} WHERE order_id = %d", $arg1->order_id);
      if (strlen($arg1->payment_details['pm_other_description']) > 0) {
        db_query("INSERT INTO {uc_payment_other} (order_id, description) VALUES " . "(%d, '%s')", $arg1->order_id, $arg1->payment_details['pm_other_description']);
      }
      break;
  }
}