Skip to content

Instantly share code, notes, and snippets.

@ideadude
Last active January 7, 2020 16:17
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 ideadude/99a8cfe787fe72d6d6af018e7eefe637 to your computer and use it in GitHub Desktop.
Save ideadude/99a8cfe787fe72d6d6af018e7eefe637 to your computer and use it in GitHub Desktop.
Use a default discount code for the PMPro checkout page.
<?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