You are here

function uc_paypal_form_alter in Ubercart 5

Same name and namespace in other branches
  1. 6.2 payment/uc_paypal/uc_paypal.module \uc_paypal_form_alter()

Implementation of hook_form_alter(). Notice how we alter the checkout review form to post the order to PayPal.

File

payment/uc_paypal/uc_paypal.module, line 93
Integrates various PayPal payment services and Instant Payment Notifications (IPN) with Ubercart!

Code

function uc_paypal_form_alter($form_id, &$form) {
  if ($form_id == 'uc_cart_checkout_review_form' && ($order_id = intval($_SESSION['cart_order'])) > 0) {
    $order = uc_order_load($order_id);
    if ($order->payment_method == 'paypal_wps') {
      unset($form['submit']);
      $form['#prefix'] = '<table style="display: inline; padding-top: 1em;"><tr><td>';
      $form['#suffix'] = '</td><td>' . drupal_get_form('uc_paypal_wps_form', $order) . '</td></tr></table>';
    }
  }
  if ($form_id == 'uc_cart_checkout_form' && variable_get('uc_payment_method_paypal_ec_checkout', FALSE)) {
    $form['#submit'] = (array) $form['#submit'] + array(
      'uc_paypal_ec_checkout' => array(),
    );
  }
  if ($form_id == 'uc_cart_checkout_review_form' && !empty($_SESSION['TOKEN'])) {
    $form['#submit'] = (array) $form['#submit'] + array(
      'uc_paypal_ec_submit_form_submit' => array(),
    );
  }
}