Ubercart checkout: when clicking to review order, do some additional validation
When a user goes to checkout and clicks on "review", I would like to be able to开发者_如何学Go hook into that process in order to do some custom validation.
How would I go about doing that?
If you want to add fields to the form you need to implement your own checkout pane (see this page for a good example).
If you just literally want to add some extra validation you should be able to do it in a custom module by implmenting hook_form_FORM_ID_alter:
function mymodule_form_uc_cart_checkout_form_alter(&$form, &$form_state) {
$form['#validate'][] = 'mymodule_checkout_form_validate';
}
function mymodule_checkout_form_validate(&$form, &$form_state) {
if ($form_state['values']['something'] != 'something else') {
form_set_error('something', 'Something went wrong.');
}
}
精彩评论