Drupal Commerce alter checkout form and custom validate
2016-06-01 15:06
260 查看
Drupal Commerce: How to alter the checkout form and how to add the custom validation
Commerce has its own API http://api.drupalcommerce.org/, that we have used it to adapt the checkout form to our requirements.Description of the required functionality
In the billing information of an order we have added the fields “Request invoice” and “NIF/CIF” (ID). By default the field “Request invoice” is not checked and “NIF/CIF” is hidden and not required. When the buyer checks the field “Request invoice”
the field “NIF/CIF” becomes visible and required.
Proposed solution
Adding the code that changes the field “NIF/CIF” when the user checks “Request invoice”. By using hook_form_FORM_ID_alter(&$form, &$form_state, $form_id)
Adding a callback to validate the form hook_commerce_checkout_pane_info_alter(&$checkout_panes)
Adding the validation function commerce_billing_pane_validate(&$form, &$form_state, $checkout_pane, $order)
Step 1. Adding the alter form to add the behavior of the field. field_request_invoice
?
?
?
We hope this is of help. If you know another way to do this or you have another idea you can write a comment. Thanks!
相关文章推荐
- Java之反射机制
- Codeforces Round #352 (Div. 2) D. Robin Hood
- fszipx.exe
- ObjC的Block中使用weakSelf/strongSelf @weakify/@strongify
- 【整理】jQuery知识点4
- ul+li实现类似table的自适应宽度布局
- C#文件下载(实现断点续传)
- AWT入门 Frame篇
- 如何使 maven+jetty运行时不锁定文件
- Centos7 Firewalld 自定义富规则
- Android:安卓Touch事件分发机制
- 【整理】jQuery知识点3
- Unique Binary Search Trees
- UITableView优化——UITableViewCell高度的优化
- javascript 中的console.log的作用
- 团队第二次冲刺08(6.01)
- Hibernate基础学习(九)—9999
- Vim 快捷键
- redis哨兵(sentinel)原理
- 在Linux中使用线程