Forked from strangerstudios/pmpro_checkout_level.php
Last active
November 13, 2018 11:53
-
-
Save kimcoleman/4d494574fe9a64285ab94effd6ccf3d9 to your computer and use it in GitHub Desktop.
Discount a Paid Memberships Pro level half way through the year.
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 | |
/* | |
* Add this code into a custom plugin. Combine this with the pmpro-set-expiration-date and/or pmpro-subscription-delay plugins | |
* to have memberships expire/renew on the same date, e.g. Y2-01-01 to expire/renew on Jan 1 next year. | |
* | |
* You can update the logic to check for different months or adjust the price in a different way. The code below divides the | |
* initial payment by 2 July 1 through Dec 31. | |
*/ | |
function pmpro_checkout_level_half_off_mid_year( $level ) { | |
$month = date( 'n', current_time( 'timestamp' ) ); | |
if ( $month > 6 ) { | |
//July or later | |
if ( $level->initial_payment > 0 ) { | |
$level->initial_payment = number_format( $level->initial_payment/2, 2 ); | |
} | |
} | |
return $level; | |
} | |
add_filter( 'pmpro_checkout_level', 'pmpro_checkout_level_half_off_mid_year' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment