• Hi, This code I can “See” is working and the checkbox is checked on page load, BUT it is automatically unchecked? This code below automatically selects the checkbox, BUT WHAT removes it? Why or what is WC doing that it unchecks the box?

    
    add_action( 'woocommerce_after_checkout_form', 'autocheck' );
    function autocheck(){
    	
      ?>
      <script>
    	  
    	  jQuery(document).ready(function () {
        jQuery('#gifting_999_option').attr('checked', 'checked');
    });
    	 
    </script>
      <?php
    }
    

    Note: this is the gift subscription checkbox viewed ON the checkout page. Its the checkbox you click to add the gift recipient email address. I need it automatically check because the buyer does NOT need to check it. It should automatically checked?

    thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • laceyrod

    (@laceyrod)

    Automattic Happiness Engineer

    Hi there,

    Thanks for reaching out. While I wasn’t even able to get that snippet to work on my own test site, I found an alternative that did the trick. Would you mind testing this filter out by adding it to your theme’s functions.php file?

    add_filter('wcsg_recipient_checkbox_checked', '__return_true');

    Alternatively, you can also use a plugin like Code Snippets to safely add this code: https://www.ads-software.com/plugins/code-snippets/

    Let me know how this goes!

    Thread Starter sayze35

    (@sayze35)

    Hi @laceyrod

    note: this field is for the WC Gift Subscription checkbox, where the “gifting_999_option” ID is unique to your check…. you need to change the _999_ to your specific field name.

    wcsg_recipient_checkbox_checked is for the email of the customer, which is not the same field.

    add_filter(‘wcsg_recipient_checkbox_checked’, ‘__return_true’);
    is hardcode for the WC…. there isn’t one for WC Gift Subscription?

    OR is there?

    FYI. my original code does check the box, but something is removing the autocheck, assuming the hook is TOO EARLY? but what hook should I use that is later?

    Thread Starter sayze35

    (@sayze35)

    Hello… I was incorrect, your code does keep the check box checked ??

    but it doesn’t display, the recipient email field? How to do that?

    THANKS!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘checkout page gift subscription au’ is closed to new replies.