Created
August 17, 2017 16:25
-
-
Save strangerstudios/425c024d711e65480d53edef783e6fa1 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
There is an error on line 10. We can't edit these gists under the strangerstudios user anymore. You can find the updated/fixed gist here: https://gist.github.com/kimcoleman/4d494574fe9a64285ab94effd6ccf3d9