Forked from kimwhite/pmpro-change-price-by-date.php
Last active
January 20, 2025 16:21
-
-
Save MaximilianoRicoTabo/5bf7bc882ec88bce62470f8772059e2c to your computer and use it in GitHub Desktop.
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 // do not copy this line. | |
/** | |
* This recipe does will change the price for a membership by the date | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function pmpro_checkout_sale_price( $level ) { | |
$month = date( 'n', current_time( 'timestamp' ) ); | |
if ( in_array( $month, array( 1, 2, 3 ) ) ) { | |
$level->initial_payment = number_format( $level->initial_payment + 20, 2 ); | |
} | |
return $level; | |
} | |
add_filter( 'pmpro_checkout_level', 'pmpro_checkout_sale_price' ); | |
/* change price by month text */ | |
function nicer_pmpro_level_cost_text($text, $level) | |
{ | |
global $pmpro_pages; | |
$month = date( 'n', current_time( 'timestamp' ) ); | |
if ( is_page( $pmpro_pages['levels'] ) && in_array( $month, array( 1, 2, 3 ) ) ) { | |
//Change this text below to match your needs. | |
$text = number_format( $level->initial_payment + 20, 2 ) . " includes 20 as a late checout fee."; | |
} | |
return $text; | |
} | |
add_filter("pmpro_level_cost_text", "nicer_pmpro_level_cost_text", 15, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment