Commerce: Diffrent text to add to cart button in product list and in product page i try to modify the add to cart button text in commerce so i can have diffrent text in product list and diffrent text in product page.

Is it possible to do this with form_alter?

I tried to use something like node type but no success.

function custom_addtocart_form_alter(&amp;$form, &amp;$form_state, $form_id) {

    if ((substr($form_id, 0, 30) == 'commerce_cart_add_to_cart_form') &amp;&amp; $node-&gt;type == 'product_display') {
    $form['submit']['#value'] = t('Buy');
    }
}


Thanks
You should be able to use $node->type if you add this first

$node = menu_get_object();


Remember to check if $node is NULL and $node->type is set.

Also if you're wanting to use the "add to cart" hook_FORM_ID_alter() then the function name needs to be something like

custom_form_commerce_cart_add_to_cart_form_alter()