Skip to content

Instantly share code, notes, and snippets.

@amdrew
Last active August 29, 2015 14:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save amdrew/028cda80cb607a8e6e99 to your computer and use it in GitHub Desktop.
Easy Digital Downloads - Deselect other multicheck pricing options when last one is selected
<?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