If we have commerce checkout enable for anonymous (New Customers), after submitting registration form, legal module force redirect to /legal_accept and breaks checkout process. Below are the details
1. We should add legal field for commerce checkout registration forms as well. We should alter the this form in legal.module the way we are doing registration form. As interim solution I am using hook_form_alter in custom module to add field in form with $form_id = commerce_checkout_flow_multistep_default
legal_display_fields($form['email_registration_login']['register'], $conditions, 'registration');
2. Since commerce forms follow field-set/panes, we are getting \Drupal::request()->request->get('legal_accept'); as empty in legal_user_insert and instead. As interim solution I am using below solution in custom module ( example_user_insert)
function my_module_user_insert(EntityInterface $entity) {
$language = \Drupal::languageManager()->getCurrentLanguage();
$post = \Drupal::request()->request->get('email_registration_login');
$accepted = $post['register']['legal']['legal_accept'] ? TRUE : FALSE;
if ($accepted) {
module_load_include('module', 'legal');
$conditions = legal_get_conditions($language->getId());
if (empty($conditions['conditions'])) {
return;
}
legal_save_accept($conditions['version'], $conditions['revision'], $conditions['language'], $entity->get('uid')
->getString());
}
}| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3116700-commerce-checkout-checkboxes-5.patch | 2.3 KB | mrweiner |
Comments
Comment #2
rsingh27 commentedComment #3
introfini commentedGreat workaround. Thanks!
Comment #4
tiburi commentedHello, I'm happy to found this post.
Can you explain easier how can I fix this issue?
Is there any patch to solve this?
Thank you so much!
Comment #5
mrweiner commentedAttaching a patch that brings in the workaround from the initial issue description. Initial issue report had the right idea, but instead of
legal_display_fields($form['email_registration_login']['register'], $conditions, 'registration');I needed to uselegal_display_fields($form['login']['register'], $conditions, 'registration');. Patch adds a function to grab the pane ids in case additional cases exist that need to be checked.Comment #6
mrweiner commentedComment #7
savage1974 commentedThe patch works OK! Thanks a lot!
But there is one problem with form validation - when T&C is not checked - there is no any message that the checkbox is not checked. The same goes for Additional Checkboxes.
Perhaps someone has already found a solution to this problem?
best regards,
Savage
Comment #8
anybodyIs this issue still existing with 3.x? Then the version should be changed to 3.0.x please.
Comment #9
anybodyDevelopment happens in 3.x - can this still be reproduced there?