Is there any way to run hook_form_alter based on a form ’s class instead of it’s ID? Is there any way to run a hook_form_alter based on a form ’s class instead of it’s ID?

I have a class of commerce products and am needing to do form alterations on their add to cart forms. There are too many of them to do this using their form id’s. 

Pseudo code might be:

function  theme_form_alter(&amp;$form, &amp;$form_state, $form_class) {
    //code goes here
    }
No - forms are only referred to by their ID (or 'base ID'), which is essentially the name of the function that defines them, or generally speaking, closely related to it.

So if you have

function MYMODULE_some_form($form, &amp;$form_state) {
  // ...
}


Then the ID of that form is MYMODULE_some_form. It's not related to the HTML ID attribute, in case that's what you're thinking, so there's no class equivalent.