1

I've added the Cheque module to my Drupal Commerce site so that users can select that payment option instead of paying by credit card.

However, I'm seemingly unable to edit the label for that payment option which currently reads as 'Cheque' next to the radio button.

In hook_form_alter, I'm attempting the following, but all it does is add another radio button and another option...it doesn't change the existing option.

$form['commerce_payment']['payment_method']['#options']
['commerce_payment_commerce_cheque'] = t('Send me an Invoice');

Note: I also tried the above code with ['#title'] at the end and it just gives me another option with the label 'Array' attached to it.

So, how do you change the label text of an option with hook_form_alter?

2

You're just adding to the existing array of options, when actually you want to clear it and just use your option.

Try this...

$form['commerce_payment']['payment_method']['#options'] = array('commerce_payment_commerce_cheque' => t('Send me an Invoice'));

| improve this answer | |
1

You could also try Commerce Payment Alter module. In that case no custom development would be required.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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