What is the easiest way to change the Add to cart form button text to something custom? I want to change the text only on certain product types. How should I approach this?


Take help of hook_form_alter. Get the ID of the form for the product display where you are trying to change the text & do something like this --

function MYMODULE_form_alter(&$form, &$form_state, $form_id){//replace your module name with MYMODULE
  if(strpos($form_id, 'commerce-cart-add-to-cart-form-65') !== false){//my form ID is "commerce-cart-add-to-cart-form-65", replace it with your form ID.
    $form['submit']['#value'] = t('Check Out');//Put the text which you want to make appear instead of "Add to cart".

I also have several product display with custom text for "Add to cart". It took some time for me figure out the easy way. Have Fun :)

| improve this answer | |
  • I'm using a Bootstrap module and I found this changed the class of the button from "btn-success" to "btn-default". I can't explain why but it is 100% repeatable :/ – Craig Nov 24 '13 at 21:23

The module works great.stringoverrrides

| improve this answer | |
  • This will change it site wide. OP wants to do it for just a certain product type. – Nigel Waters Aug 10 '13 at 14:20

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.