You are here

function commerce_paypal_checkout_get_payment_method_instance in Commerce PayPal 7.2

Returns the first configured PayPal checkout payment method instance for the given order, if any.

Parameters

$order: The order that needs to be checked.

Return value

array|bool The first payment method instance found for given order, FALSE otherwise.

1 call to commerce_paypal_checkout_get_payment_method_instance()
commerce_paypal_checkout_form_alter in modules/checkout/commerce_paypal_checkout.module
Implements hook_form_alter().

File

modules/checkout/commerce_paypal_checkout.module, line 828
Implements PayPal Checkout in Drupal Commerce checkout.

Code

function commerce_paypal_checkout_get_payment_method_instance($order) {
  if (empty($order->payment_methods)) {
    $order->payment_methods = array();
    rules_invoke_all('commerce_payment_methods', $order);

    // Sort the payment methods array by the enabling Rules' weight values.
    uasort($order->payment_methods, 'drupal_sort_weight');
  }
  foreach (array_keys($order->payment_methods) as $instance_id) {

    // Explode the method key into its component parts.
    list($method_id) = explode('|', $instance_id);
    if ($method_id != 'paypal_checkout') {
      continue;
    }
    return commerce_payment_method_instance_load($instance_id);
  }
  return FALSE;
}