I have the following form
function beyond_shipping_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if ($form_id == 'commerce_checkout_flow_multistep_default') {
$default_challenge = \Drupal::service('config.manager')
->getConfigFactory()
->get('captcha.settings')
->get('default_challenge');
$form['captcha'] = [
'#type' => 'captcha',
'#captcha_type' => $default_challenge,
];
}
}
The google captcha appears perfectly when the page loads but disappears upon calculating the shipping costs.
From my understanding, the shipping cost calculator reloads the whole form without the google captcha. Therefore, the google captcha validation becomes invalid upon recalculating the cost and the google captcha is not rendered on the page.
The problem is that I don't know where exactly I should make the change in my module to "hook" to the change and rerender the google captcha again. I was struggling to find info about this but didn't manage.
I appreciate your help.