How do I alter the Price Component Title in Commerce Userpoints Discount without altering the module? It seems that when a user adds a Userpoints Discount line item to their shopping cart it appears in the footer as 'Royalty', which will be totally confusing to users.

On line #382 of commerce_userpoints_discount.module there is this code:

function commerce_userpoints_discount_commerce_price_component_type_info() {
  return array(
    'userpoints' =&gt; array(
      'title' =&gt; t('Royalties'),
      'display_title' =&gt; t('Royalties'),
      'weight' =&gt; 1000,
    ),
  );
}


Without hacking this module, is there a way I can change this description? In my case, we will be using -two- Userpoints currencies (depending on the type of product the user orders) and we would like the description in the footer to be that userpoints description.

What I've already tried is to create my own hook with a higher weight. My hope was that my hook would take precedence over the default, but apparently not. Perhaps I don't understand 'hooks' well enough yet. If so, could someone tell me how to make -my- hook take precedence?

function my_module_commerce_price_component_type_info() {
  return array(
    'userpoints' =&gt; array(
      'title' =&gt; t('My Userpoints Currency'),
      'display_title' =&gt; t('My Userpoints Currency'),
      'weight' =&gt; 2000,
    ),
  );
}


In short, we want the Price Component title to match the currency type of Userpoints on the line item.
The implementations of hook_commerce_price_component_type_info() are invoked from commerce_price_component_types(), which uses the following code.

  // If it did not exist, fetch the types now.
  if (!isset($component_types)) {
    // Find components defined by hook_commerce_price_component_type_info().
    $component_types = module_invoke_all('commerce_price_component_type_info');

    // Add default values to the component type definitions.
    foreach ($component_types as $name =&gt; &amp;$component_type) {
      $component_type += array(
        'name' =&gt; $name, 
        'display_title' =&gt; $component_type['title'], 
        'weight' =&gt; 0,
      );
    }

    // Allow the info to be altered by other modules.
    drupal_alter('commerce_price_component_type_info', $component_types);
  }


As with other hooks, if you want to alter what an hook implemented from another module returns, you need to implement an alter hook.

In your case, the code should be similar to the following one.

function my_module_commerce_price_component_type_info_alter(&amp;$component_types) {
  if (isset($component_types['userpoints'])) {
    $component_types['userpoints']['title'] = t('My Userpoints Currency');
    $component_types['userpoints']['display_title'] = t('My Userpoints Currency');
    $component_types['userpoints']['weight'] = 2000;
  }
}


Generally speaking, this is only possible when the module using the hook is also calling drupal_alter(), such as in this case.