I have tried the following code:
// Add [recaptcha] shortcode
if ( class_exists('WP_reCaptcha') )
add_shortcode( 'recaptcha' , array( WP_reCaptcha::instance() , 'recaptcha_html' ) );
// Customizing checkout fields using actions and filters
add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' );
function my_custom_checkout_field( $checkout ) {
echo '<div id="my_captcha"><label>' . __('Captcha') . '</label>';
echo do_shortcode('[recaptcha]');
echo '</div>';
}
add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');
// Valided error
function my_custom_checkout_field_process() {
// Check if set, if its not set add an error.
if ( !WP_reCaptcha::instance()->recaptcha_check() )
wc_add_notice( __( 'Please enter correct captcha.' ), 'error' );
}
With this it appeared, but it not validating the click and is raising a error:
“Error: Invalid ReCAPTCHA client id: 0”
Which version of the plugin do you have?
Ok, cause the behavior you describe was showing in a different version.
Do you have another plugin installed that has also a reCaptcha functionality? I have noticed sometimes some weird interactions when more than one plugin can do reCaptcha.