1

I've been poking around in various forums trying to change the hard-coded values for the Checkout Page buttons and titles. For semantic reasons, I want to change the last submit button from 'Continue to next step' to 'Complete Submission'.

I have had success in changing the other buttons with combinations of hook_form_alter() and how hook_menu_alter()

function bartik_form_alter(&$form, &$form_state, $form_id){
dpm($form_id);
dpm($form);
if (commerce_form_callback($form_id, $form_state) == "commerce_cart_add_to_cart_form"){
    $form['submit']['#attributes']['title'] = $form['submit']['#attributes']['value']=t("Add to Inquiry List");
    }
if(strpos($form_id, 'views_form_commerce_cart_form_default')===0){
    $form['actions']['submit']['#value'] = t("Update List");
    $form['actions']['checkout']['#value'] = t("Submit List");

    }   

However, I am having problems changing the final submit button in the commerce_checkout_form_review form. I've tried the method suggested here http://mtt.desk.com/customer/portal/articles/1430204-how-to-customize-the-label-of-the-drupal-commerce-button-on-the-order-review-page, both as a module and as a function in the theme template, but neither method produces an error or gives me the desired text change.

function co_button_commerce_checkout_page_info_alter(&$checkout_pages) {
$checkout_pages['review']['submit_value'] = 'Submit Order';
}

So, I've been trying a couple of different variations, but I'm still not sure how to target the buttons on that form. I have also tried this little if statement, but it's still not effecting the change.

if(strpos($form_id, 'views_form_commerce_cart_form_default')===0){
$form['buttons']['continue']['#value'] = t('Complete submission');
}}  

TIA, any advice would be greatly appreciated.

I think this is the relevant portion of the array

buttons (Array, 4 elements)
#type (String, 8 characters ) fieldset
#attributes (Array, 1 element)
continue (Array, 6 elements)
#type (String, 6 characters ) submit
#value (String, 21 characters ) Continue to next step
#attributes (Array, 1 element)
#suffix (String, 59 characters ) <span class="checkout-processing element-      
#validate (Array, 1 element)
#submit (Array, 1 element)
0

I think you can handle it with hook_form_later, try something like below, change your condition according to your checkout base name , I hope this help you :

/**
 * Implements hook_form_alter().
 */
function yourmodule_form_alter(&$form, &$form_values, $form_id) {
  if($form['checkout_pane']['#value']['base'] == 'checkout_pane_review') {
    $form['submit']['#value']='yourvalue';
  }
}
0

Since all you're doing is trying to change the button text, you really should just be altering the checkout page info array for the relevant checkout page so its "submit_value" reads as you want it to read. It looks like you got this right, and other folks can refer to the documentation in commerce_checkout.api.php for more information.

If you add this alter function to a module or theme that's already installed on the site, remember you need to clear the cache for the hook to register and actually start altering the array.

  • good to know I'm barking up the right tree, but I guess I'm not clear on exactly how the buttons are being targetted. At this point I know it's the commerce_checkout_form_review form, but I'm still not sure about how to pull the identifying info out of the $form variable array above. – nizz0k May 20 '14 at 19:51
  • 1
    turns out, I missed a curly brace, but it didn't trigger an error. thanks! – nizz0k May 20 '14 at 22:59
  • Hah, weird. Gotta love silent failures. : P – Ryan Szrama May 22 '14 at 18:05

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.