Easy Digital Downloads - Deselect other multicheck pricing options when last one is selected
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
<?php | |
function sumobi_edd_deselect_other_price_options() { | |
if ( ! edd_has_variable_prices( get_the_ID() ) ) | |
return; | |
?> | |
<script> | |
jQuery(document).ready(function ($) { | |
// get each purchase form | |
var purchaseForm = $( '.edd_download_purchase_form' ); | |
$( purchaseForm ).each(function( index ) { | |
var allCheckBoxes = $( "input[type=checkbox]", this ), | |
last = allCheckBoxes.last(); | |
// last checkbox is clicked | |
$( last ).click( function() { | |
// check to see if it's checked | |
if ( $( this ).prop('checked') ) { | |
// deselect all other checkboxes | |
$( allCheckBoxes ).not( this ).prop( "checked", false ); | |
} | |
}); | |
}); | |
}); | |
</script> | |
<?php | |
} | |
add_action( 'wp_footer', 'sumobi_edd_deselect_other_price_options' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment