You are here

commerce_sermepa_v_me.module in Commerce sermepa 7

Provides a payment method for Drupal Commerce using v.me gateway.

File

modules/commerce_sermepa_v_me/commerce_sermepa_v_me.module
View source
<?php

/**
 * @file
 * Provides a payment method for Drupal Commerce using v.me gateway.
 */

/**
 * Implements hook_form_FORM_ID_alter().
 */
function commerce_sermepa_v_me_form_commerce_checkout_form_alter(&$form, &$form_state) {

  // If this checkout form contains the payment method radios...
  if (!empty($form['commerce_payment']['payment_method']['#options'])) {

    // Loop over its options array looking for a Commerce Sermepa v.me options.
    foreach (array_keys($form['commerce_payment']['payment_method']['#options']) as $key) {
      list($method_id, $rule_name) = explode('|', $key);

      // If we find Commerce Sermepa iupay, change the display title.
      if (strpos($rule_name, 'commerce_payment_sermepa_v_me_payment') !== FALSE) {
        $v_me_button = array(
          'path' => drupal_get_path('module', 'commerce_sermepa_v_me') . '/images/v-me.png',
          'title' => 'v.me by Visa',
          'alt' => 'v.me by Visa',
          'attributes' => array(
            'class' => array(
              'commerce-sermepa-icon',
            ),
          ),
        );
        $logo = theme('image', $v_me_button);
        $display_title = t('!logo - pay with v.me by Visa', array(
          '!logo' => $logo,
        ));
        $form['commerce_payment']['payment_method']['#options'][$key] = $display_title;
      }
    }
  }
}