I need to display another label for quantity field, what the best way to do that, I don't see any option for it.

Comments

malberts’s picture

You will need to write a little module that alters the add to cart form. You can then change the quantity field label in there.

For example:

function MY_MODULE_form_commerce_cart_add_to_cart_form_alter(&$form, &$form_state) {
  $form['quantity']['#title'] = t('New label');
}
heyyo’s picture

Yes I did that:

function alter_commerce_form_alter(&$form, &$form_state, $form_id) {
  if (strstr($form_id, 'commerce_cart_add_to_cart_form')) {
    if (isset($form['line_item_fields']['#entity']->type)) {
      $type = $form['line_item_fields']['#entity']->type;
      if ( $type == 'my_custom_line_item'){
        $form['quantity']['#title'] = t('My NEW label for quantity');
        $form['attributes']['field_color']['#title'] = t('Select Color');
      }
    }
  }
}

But it doesn't work because Commerce Kickstart is also altering this field. Any idea how to make my module the last module altering this label ?

malberts’s picture

Have a look at: http://drupal.org/node/110238

You can use the hook_install code on that page. Then you'll have to uninstall and reinstall your module first before it works. You could also just manually update the database (doing what the query would do) but if you use this module elsewhere then you will have to do it again.

ahimsauzi’s picture

That is why we love Drupal :(

nvahalik’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Marking as closed.