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' => array(
      'title' => t('Royalties'),
      'display_title' => t('Royalties'),
      'weight' => 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' => array(
      'title' => t('My Userpoints Currency'),
      'display_title' => t('My Userpoints Currency'),
      'weight' => 2000,

In short, we want the Price Component title to match the currency type of Userpoints on the line item.

Order footer. We want to change Royalty to match the line item description of the Userpoints Discount.

1 Answer 1


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 => &$component_type) {
      $component_type += array(
        'name' => $name, 
        'display_title' => $component_type['title'], 
        'weight' => 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(&$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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.