开发者

Ubercart checkout: when clicking to review order, do some additional validation

开发者 https://www.devze.com 2023-04-12 10:10 出处:网络
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.

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.');
  }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号