I'm using the Drupal WorldPay module (for Commerce 7.x-1.11).

On the checkout page it says "Pay via WorldPay". I want to change this. I've traced it back to a line in the module:

function commerce_worldpay_bg_commerce_payment_method_info() {
  $payment_methods = array();

  $payment_methods['commerce_worldpay_bg'] = array(
     'title' => t('Payment via Worldpay'),
     'description' => t('Integration with Worldpay\'s Business Gateway method.'),
     'active' => TRUE,
     'offsite' => TRUE,
     'offsite_autoredirect' => TRUE,
     'callbacks' => array(),

  return $payment_methods;


'title' => t('Payment via Worldpay'),

I think I can override this in the theme template.php but have no idea how, and there seems to be very few instructions on how one might go about it.

2 Answers 2


In this specific case, you can implement hook_commerce_payment_method_info_alter(&$payment_methods) in a custom module, and alter $payment_methods['commerce_worldpay_bg']['title'].

If you see other instances of the strings, which aren't changed, then you can use the String Overrides module, as already suggested, or use the $conf global variable in settings.php as follows.

$conf['locale_custom_strings_en'][''] = array(
  'Payment via Worldpay' => 'Your string',

Keep in mind that the latter two methods change the string wherever it is used; they don't provide a context to understand where the string is being used. This could be something you want, or not.


There are of course different ways you can solve your problem (e.g., by overwriting the title value in a preprocess function, in a custom theme or module). It mostly depends on taste and the structure the solution has to be.

However, in situations where you simply need to replace text on a site in an easy way, the String Overrides module comes quite in handy. It allows you to replace anything that is passed through a t() function.

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.