Drupal 9 Commerce change the Pay button text

cn flag

I have created Drupal 9 website. On the website we accept donations using Commerce with Commerce Stripe as the payment processor. By default, the payment button says "Pay and complete purchase". As users are not purchasing anything, I want to change the text to something like "Donate Now". I have searched for answers online but all seem to point to the module String Overrides, which is D7 only and doesn't look like is will have a D8/9 option.

Any idea how to change the text in Drupal 9?

cn flag
There is a [dev version of String Overrides that has Drupal 9 support](, but dev versions may have unforeseen bugs. If you can write code, you can use `hook_form_alter()` to override the text on the payment form in a custom module.
FrankDesign avatar
cn flag
Thanks Patrick. I tried hook_form_alter but it's not working. The problem is that the form ID is the same across all the forms in the checkout process. I only want to target the last step. The code I have in my theme file is `use Drupal\Core\Form\FormStateInterface; /** * Implements hook_form_FORM_ID_alter(). */ function mytheme_form_alter(&$form, FormStateInterface &$form_state, $form_id) { if($form_id = "commerce-checkout-flow-multistep-default") { $form['actions']['submit']['#value'] = t('Pay Now'); } }`

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.