Forked from andrewlimaza/remove-vp-pricing-discounut-code.php
Last active
September 23, 2020 15:28
-
-
Save dparker1005/586c5824b14867813b04e5b71966d9ab to your computer and use it in GitHub Desktop.
Remove variable pricing check and hide errors when discount code is applied.
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 | |
// 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