Created
December 1, 2020 04:26
-
-
Save grayayer/bc1d819012ba20509d5bf2d4bb6ee63d to your computer and use it in GitHub Desktop.
WooCommerce Subscription product page with gifted subscriptions checkbox gets auto clicked upon page load.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function auto_select_gift() { | |
if ( is_single(56669) ) { //enter product id here | |
?> | |
<script type="text/javascript"> | |
jQuery(document).ready(function ($) { | |
document.getElementById("gifting_0_option").click(); // Click on the checkbox | |
}); | |
</script> | |
<?php | |
} | |
} | |
add_action('wp_head', 'auto_select_gift'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The purpose of this is to make it painfully obvious on a certain product, that it is intended to be used for gifting, rather than buying for oneself.