• Resolved JapeNZ

    (@japenz)


    Hi there,
    Is it possible to place the reCaptcha box at the bottom of the billing details area in the Woocommerce checkout page, rather than at the bottom of the page please?

    I’m not sure if this is already possible… is there an option I’ve overlooked perhaps?
    If not, is there a way I can manually reposition it?

    Thank you for your help!

    Kind regards,
    JP

Viewing 10 replies - 1 through 10 (of 10 total)
  • I would also like to move the captcha up a little bit where people can actually see it.

    I didn’t want to mess with the actions used to place the captcha form (although the author should probably choose to do so).

    Meanwhile, I also didn’t get good results with a simple CSS relative position, so I used jQuery to move the captcha, 1 second after page load:

    setTimeout(
                function()
                {
                    $('.woocommerce-terms-and-conditions-wrapper').append( $('.anr_captcha_field') );
                }, 2000);

    A proper solution should however be integrated into the plugin by the author, as the position of the captcha was leading to many people getting errors and not checking out.

    Thread Starter JapeNZ

    (@japenz)

    @adaldesign
    Good job buddy ??

    I have no idea how to implement jQuery haha!
    As an alternative, I created a copy of the Woocommerce ‘form-billing.php’ template (woocommerce > templates > checkout) and placed it in my child theme (child-theme > woocommerce > checkout ).

    Then added this below the “woocommerce-billing-fields__field-wrapper” div on line 43:
    <?php do_action( 'anr_captcha_form_field' ); ?>

    So it looks like this:

    <div class="woocommerce-billing-fields__field-wrapper">
    		<?php
    		$fields = $checkout->get_checkout_fields( 'billing' );
    
    		foreach ( $fields as $key => $field ) {
    			woocommerce_form_field( $key, $field, $checkout->get_value( $key ) );
    		}
    		?>
    	</div>
    	<?php do_action( 'anr_captcha_form_field' ); ?>

    Seems to have done the trick, though as you mention having an integrated option in the plugin would be ideal ??

    • This reply was modified 5 years, 2 months ago by JapeNZ.

    Nice one Jape!

    I ended up using your solution as it is cleaner.

    I was working on a function instead but couldn’t get it to work. So far I got:

    function change_anr_actions() {
    	if ( anr_is_form_enabled( 'wc_checkout' ) ) {
    	    print '<!-- NEW TEST 3 -->';
    		remove_class_hook( 'woocommerce_checkout_after_order_review', 'anr_captcha_class', 'wc_form_field' );
            add_action( 'woocommerce_checkout_order_review', 'anr_captcha_form_field' );
    	}
    }
    // add_action( 'wp_head', 'change_anr_actions' );
    
    /*
     *  Function to remove Actions from within Classes we can't overwrite
     */
    function remove_class_hook( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
    	global $wp_filter;
    	$is_hook_removed = false;
    	if ( ! empty( $wp_filter[ $tag ]->callbacks[ $priority ] ) ) {
    		$methods     = wp_list_pluck( $wp_filter[ $tag ]->callbacks[ $priority ], 'function' );
    		$found_hooks = ! empty( $methods ) ? wp_list_filter( $methods, array( 1 => $method_name ) ) : array();
    		foreach( $found_hooks as $hook_key => $hook ) {
    			if ( ! empty( $hook[0] ) && is_object( $hook[0] ) && get_class( $hook[0] ) === $class_name ) {
    				$wp_filter[ $tag ]->remove_filter( $tag, $hook, $priority );
    				$is_hook_removed = true;
    			}
    		}
    	}
    	return $is_hook_removed;
    }

    Adal

    Thread Starter JapeNZ

    (@japenz)

    @adaldesign
    Unfortunately it seems that using the template option removes the ability of the ‘Hide Captcha for logged in users?’ option… damn it! xD

    As the majority of my customers are subscribers with accounts, it’s more important for me to be able to hide it for logged in users than position it nicely for guests.

    Hopefully this won’t effect your website as much… back to the drawing board for me!

    @shamim51 any thoughts on how I can hide the Captcha for logged in users when using do_action( ‘anr_captcha_form_field’ ) to position it in the billing area?

    Do you think you might be able to add the option of placing the Captcha in the billing area in a future release?

    Thanks for your help guys!

    • This reply was modified 5 years, 2 months ago by JapeNZ.

    @adaldesign
    woocommerce_checkout_order_review shows the captcha above payment options which is also not looking good.

    @japenz
    You can follow last couple of commits in https://github.com/shamim2883/advanced-nocaptcha-recaptcha which solve the issue.

    I am working on a new version, but i am too busy. May be after couple of weeks i will be able to release a new version. Any pull request in github is highly appreciated.

    Thread Starter JapeNZ

    (@japenz)

    Hi @shamim51,
    Thank you for the updates!

    So if I delete the plugin then install it again will the new commits be applied?
    Or should I download the master zip from github… or manually apply the new commits?

    Sorry I’ve not updated a plugin this way before ??

    Thanks again!

    Easy way will be download master zip from github, unzip and replace files of the plugin in your website with this unzipped files using ftp/sftp or file manager.

    Thread Starter JapeNZ

    (@japenz)

    Perfect! thank you ??

    Thread Starter JapeNZ

    (@japenz)

    Update done, I can confirm that the ‘Hide Captcha for logged in users?’ option now works when using ‘do_action( ‘anr_captcha_form_field’ )’ to position the captcha in the billing area! ??

    @shamim51 thanks buddy, appreciate the effort and help!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Reposition reCaptcha on Woocommerce Checkout page’ is closed to new replies.