Skip to content

Instantly share code, notes, and snippets.

@pippinsplugins
Created October 4, 2013 15:37
Show Gist options
  • Save pippinsplugins/6827946 to your computer and use it in GitHub Desktop.
Save pippinsplugins/6827946 to your computer and use it in GitHub Desktop.
Show a message to users that have purchased the currently viewed product in EDD.
<?php
/**
* Show Has Purchased Item Message
*
* Prints a notice when user has already purchased the item.
*
* @since 1.0
* @global $user_ID
* @param int $download_id Download ID
* @return void
*/
function pw_edd_show_has_purchased_item_message() {
global $user_ID, $post;
if( !isset( $post->ID ) )
return;
if ( edd_has_user_purchased( $user_ID, $post->ID ) ) {
$alert = '<p class="edd_has_purchased">' . __( 'You have already purchased this item, but you may purchase it again.', 'edd' ) . '</p>';
echo apply_filters( 'pw_edd_show_has_purchased_item_message', $alert );
}
}
add_action( 'edd_after_download_content', 'edd_show_has_purchased_item_message' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment