When uc_ideal_pro_order() is called (operation 'submit'), UC Ideal Pro redirects the user to the page of the chosen bank. This way modules that are heavier than UC Ideal Pro do not get the chance to do their logic when an order gets submitted. I had problems when using the module uc_node_checkout, and noticed this was caused because of this.

A possible solution is to increase the weight of this module and make it heavier than the heaviest module that implements hook_order().

Comments

praseodym’s picture

Assigned: Unassigned » praseodym

Any suggestion for the value?

megachriz’s picture

I'm not sure to which value the module's weight should be set exactly, because when you set a value you can not be sure if there is yet another module available that is even heavier. uc_node_checkout has a weight of 100, so the weight should be at least set to 101.

I now have fixed it with the code beneath. This code will loop through all enabled modules that implement hook_order(). Then it asks the database what the highest weight is of those modules. It increases the returned value with one and sets the weight of uc_ideal_pro to this value. This way you are sure uc_ideal_pro is the heaviest module that implements hook_order().
The only thing I'm not sure about, is when this code should be called, but I think it should be called every time a new module gets enabled (because in theory that module could be heavier than uc_ideal_pro).

/**
 * Makes this module heavier than the heaviest module that implements hook_order().
 * @return void
 */
function uc_ideal_pro_makeheavy() {
  // Check which modules implements hook_order().
  $hook_order_modules = array();
  foreach (module_list() as $module) {
    $function = $module .'_order';
    if ($module != 'uc_ideal_pro' && function_exists($function)) {
      $hook_order_modules[] = $module;
    }
  }

  if (is_array($hook_order_modules)) {
    // Load maximum weight
    $sQuery = "SELECT max(weight) AS weight
    FROM {system}
    WHERE type='module'
    AND name IN (".db_placeholders($hook_order_modules, 'varchar').")";
    $iWeight = db_result(db_query($sQuery, $hook_order_modules));

    // Increase weight with 1
    $iWeight++;

    // Save weight
    db_query("UPDATE {system} SET weight = %d WHERE name = 'uc_ideal_pro' AND type = 'module'", $iWeight);
  }
}
summit’s picture

Subscribing, greetings, Martijn

praseodym’s picture

Assigned: praseodym » Unassigned
Status: Active » Needs work

Needs a proper patch.

praseodym’s picture

Status: Needs work » Closed (won't fix)

Feel free to reopen with a patch.