Skip to content

Instantly share code, notes, and snippets.

@michael-cannon
Created May 13, 2013 21:07
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 michael-cannon/5571534 to your computer and use it in GitHub Desktop.
Save michael-cannon/5571534 to your computer and use it in GitHub Desktop.
Add recurring period to pricing
<?php
add_filter( 'edd_purchase_download_form', 'aihrus_edd_purchase_download_form', 10, 2 );
function aihrus_edd_purchase_download_form( $purchase_form, $args ) {
$id = $args['download_id'];
$price = edd_get_download_price( $id );
if ( 0 == $price ) {
$price = '&#036;' . $price;
$replace = 'Free';
$purchase_form = str_replace( $price, $replace, $purchase_form );
} elseif ( class_exists( 'EDD_Recurring' ) && EDD_Recurring()->is_recurring( $id ) ) {
$period = EDD_Recurring()->get_period_single( $id );
if ( 'never' != $period ) {
$replace = $price . ' per ' . $period;
$purchase_form = str_replace( $price, $replace, $purchase_form );
}
}
return $purchase_form;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment