Last active
April 10, 2020 15:41
-
-
Save ronalfy/da1feb314b3e036b78fd10a6da88f19e to your computer and use it in GitHub Desktop.
Paid Memberships Pro - Discount Context for Code
This file contains hidden or 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 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