0

We have a requirement where user can do multiple registration for an event (i.e. for own and for other users). We want to restrict the user to do only N number of registration or less, where number N may vary from user to user specified on user profile. We are using 'Entity Registration' and 'Commerce Registration' module to do registration.

1

Drupal Commerce's checkout form uses button level validate and submit handlers as opposed to form level handlers. This means instead of just adding a handler to the $form['#validate'] or $form['submit'] array, you need to add it to the correct checkout button itself.

In your case, you'll add a handler to $form['buttons']['continue']['#validate'] via a form alter hook. Note that even if you prevent the form from advancing to the next page, though, that the checkout form is a special kind of form that validates and submits each fieldset independently of the form itself.

I'm not entirely sure how the registration module you're using interacts with the checkout form. However, it's possible what you may actually want is to alter the validate callback for a particular checkout pane via hook_commerce_checkout_pane_info_alter() to supply an alternate validate handler that checks your additional registration requirements and prevents that pane from submitting (which would also prevent the form from proceeding to the next page.

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.