Skip to content

Instantly share code, notes, and snippets.

View joelacevedor's full-sized avatar

Joel Acevedo joelacevedor

View GitHub Profile
@mwhiteley16
mwhiteley16 / edd_limit.php
Created July 23, 2018 18:03
EDD One Item Per Customer
// 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.
@adriannees
adriannees / nag-and-prevent-checkout.php
Last active September 29, 2018 15:07
Limit downloads on EDD
<?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(){