You are here

function uc_pma_adjustment_callback in Ubercart Payment Method Adjustments 7

Payment ajustment line item callback

1 string reference to 'uc_pma_adjustment_callback'
uc_pma_uc_line_item in ./uc_pma.module
Implements hook_uc_line_item().

File

./uc_pma.module, line 123
This module hooks into a few different parts of Ubercart to allow store administrators to associate a fee or discount with payment methods.

Code

function uc_pma_adjustment_callback($op, &$order) {
  switch ($op) {
    case 'load':
      $adjustment_order = $order;
      $lines = array();
      if (empty($adjustment_order->payment_method)) {

        //if payment_method isn't set we pick the default one
        $methods = _uc_payment_method_list();
        $default = NULL;
        if (count($methods) > 0) {
          foreach ($methods as $id => $method) {
            if ($method['checkout'] && !isset($method['express'])) {
              if (is_null($default)) {
                $default = $id;
              }
            }
          }
          $adjustment_order->payment_method = $default;
        }
      }
      $adjustment = _payment_method_adjustment($adjustment_order);
      if (isset($adjustment['description']) && isset($adjustment['value'])) {
        $lines[] = array(
          'id' => 'payment_method',
          'title' => $adjustment['description'],
          'amount' => $adjustment['value'],
        );
      }
      return $lines;
  }
}