Skip to content

Instantly share code, notes, and snippets.

@ronalfy
Last active April 10, 2020 15:41
Show Gist options
  • Save ronalfy/da1feb314b3e036b78fd10a6da88f19e to your computer and use it in GitHub Desktop.
Save ronalfy/da1feb314b3e036b78fd10a6da88f19e to your computer and use it in GitHub Desktop.
Paid Memberships Pro - Discount Context for Code
<?php
function pmpro_add_discount_code_js() {
?>
<script>
jQuery('body').on('DOMSubtreeModified', '#pmpro_level_cost', function(){
setTimeout( function() {
var html = jQuery( '#pmpro_level_cost' ).html();
if ( jQuery( '#pmpro_payment_information_fields' ).is(':visible') == false ) {
jQuery( '.pmpro_discount_code_status' ).html( html );
} else {
jQuery( '#discount_code_message' ).html( html );
}
}, 500 );
});
</script>
<?php
}
add_action( 'wp_footer', 'pmpro_add_discount_code_js' );
function pmpro_add_checkout_status_div() {
echo '<div class="pmpro_discount_code_status"></div>';
}
add_action( 'pmpro_checkout_before_submit_button', 'pmpro_add_checkout_status_div' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment