Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrewlimaza/443f74d6566556ed2a88a5c7da856889 to your computer and use it in GitHub Desktop.
Save andrewlimaza/443f74d6566556ed2a88a5c7da856889 to your computer and use it in GitHub Desktop.
Remove auto-renewal checkbox when discount code is entered. Should fix https://github.com/strangerstudios/pmpro-auto-renewal-checkbox/issues/7
<?php
// Copy from below here
function my_pmproarc_remove_checkbox_with_discount_code() {
?>
<script>
jQuery(document).ready(function() {
// After any AJAX call...
jQuery( document ).ajaxComplete(function() {
// If the current discount code was updated...
if( jQuery ( "#pmpro_level_cost p" ).length > 1) {
// Hide auto-renewal checkbox
jQuery('#autorenew').prop('checked', true );
jQuery('#pmpro_autorenewal_checkbox').remove();
<?php $_REQUEST['autorenew_present'] = 1; ?>
}
});
});
</script>
<?php
}
add_action( 'pmpro_checkout_boxes', 'my_pmproarc_remove_checkbox_with_discount_code' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment