This file contains 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
// Prevent checkout if offer already purchased | |
add_filter( 'edd_can_checkout', 'wd_limit_purchase' ); | |
function wd_limit_purchase(){ | |
$user_id = get_current_user_id(); // Get the current customer's ID | |
$downloads = edd_get_users_purchased_products( $user_id );// Get all of the products the customer has purchased in the past | |
$can_checkout = true; // Allow checkout for now | |
if ( ! empty( $downloads ) ){ // If the customer hasn't purchased anything before we don't need to go any further. | |
foreach ( $downloads as $download ){ // Loop through each product the customer has purchased before. |
This file contains 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 to the functions.php file on your child theme | |
/** Limit download purchases to one per account | |
* HT to Scott Deluzio for original code this is modified from https://scottdeluzio.com/easy-digital-downloads-limit-one-per-customer/ | |
// Give nag message if customer has bought download previously | |
add_filter( 'edd_can_checkout', 'sd_set_purchase_limit' ); | |
function sd_set_purchase_limit(){ |