Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dparker1005/586c5824b14867813b04e5b71966d9ab to your computer and use it in GitHub Desktop.
Save dparker1005/586c5824b14867813b04e5b71966d9ab to your computer and use it in GitHub Desktop.
Remove variable pricing check and hide errors when discount code is applied.
<?php
// Copy from below here...
/**
* Remove variable pricing check and hide errors when discount code is applied.
* Follow this guide to add this code snippet to your site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Visit www.paidmembershipspro.com for more information.
*/
// Remove check.
function my_pmpro_remove_vp_check_discount_code( $continue ) {
global $pmpro_level;
if ( isset( $pmpro_level->code_id ) ) {
remove_filter( 'pmpro_registration_checks', 'pmprovp_pmpro_registration_checks' );
}
return $continue;
}
add_filter( 'pmpro_registration_checks', 'my_pmpro_remove_vp_check_discount_code', 5, 1 );
// Hide errors on checkout page.
function my_pmpro_vp_checkout_boxes() {
?>
<style>
.custom-pmprovp-price {
background-color: #ffffff !important;
}
.custom-pmprovp-warning {
display: none !important;
}
</style>
<script>
jQuery(document).ready(function() {
function hide_pmprovp_errors() {
if ( typeof hide_pmprovp_errors.has_run == 'undefined' ) {
// This is the first time that the function has run
jQuery( "#price" ).addClass( 'custom-pmprovp-price' );
jQuery( "#pmprovp-warning" ).addClass( 'custom-pmprovp-warning' );
hide_pmprovp_errors.has_run = 1;
}
}
jQuery('#other_discount_code').keyup(function() {
hide_pmprovp_errors();
});
jQuery('#discount_code').keyup(function() {
hide_pmprovp_errors();
});
});
</script>
<?php
}
add_action( 'pmpro_checkout_boxes', 'my_pmpro_vp_checkout_boxes' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment