Skip to content

Instantly share code, notes, and snippets.

@danreb
Created November 6, 2012 03:48
Show Gist options
  • Save danreb/4022434 to your computer and use it in GitHub Desktop.
Save danreb/4022434 to your computer and use it in GitHub Desktop.
Change Add to Cart button label in Drupal Commerce for specific product.
<?php
/**
* Implements hook_form_alter
*
*/
function arma_form_alter(&$form, $form_state, $form_id) {
if ($form_id === 'commerce_cart_add_to_cart_form_2' || $form_id === 'commerce_cart_add_to_cart_form_1') {
$form['submit']['#attributes']['title'] = $form['submit']['#attributes']['value'] = t('Buy Corporate Membership');
}
if ($form_id === 'commerce_cart_add_to_cart_form_4' || $form_id === 'commerce_cart_add_to_cart_form_3') {
$form['submit']['#attributes']['title'] = $form['submit']['#attributes']['value'] = t('Buy Individual Membership');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment