Last active
January 7, 2020 16:17
-
-
Save ideadude/99a8cfe787fe72d6d6af018e7eefe637 to your computer and use it in GitHub Desktop.
Use a default discount code for the PMPro checkout page.
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 | |
/** | |
* Use a default discount code for the PMPro checkout page. | |
* Change the DEFAULT code to the one you want to use. | |
* You could alter this to check the $pmpro_level global to | |
* do this only for certain levels. | |
* You could add other logic to exclude existing customers/etc. | |
* Add this code to a custom plugin or Code Snippet. | |
*/ | |
function my_default_pmpro_discount_code() { | |
global $discount_code; | |
if ( empty( $discount_code ) ) { | |
$discount_code = 'DEFAULT'; //change this | |
} | |
} | |
add_action( 'pmpro_checkout_after_parameters_set', 'my_default_pmpro_discount_code' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment