You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function pw_edd_prevent_duplicate_purchase( $valid_data, $posted ) {
$cart_contents = edd_get_cart_contents();
foreach ( $cart_contents as $item ) {
if ( ! empty( $item['options']['is_upgrade'] ) ) {
continue;
}
if ( ! empty( $item['options']['is_renewal'] ) ) {
continue;
}
if ( edd_has_user_purchased( get_current_user_id(), $item['id'] ) ) {
edd_set_error( 'duplicate_item', 'You have already purchased this item so may not purchase it again. If you want to upgrade, click on My Licenses and select the next upgrade level!' );
}
}
}
add_action( 'edd_checkout_error_checks', 'pw_edd_prevent_duplicate_purchase', 10, 2 );
The text was updated successfully, but these errors were encountered:
Based on an .org ticket https://wordpress.org/support/topic/plugin-code-from-edd-library-does-not-work/ we should update our snippet to allow Renewals and Upgrades if SL is being used. https://library.easydigitaldownloads.com/checkout/prevent-duplicate-purchases.html
Working code (updated) from @robincornett
The text was updated successfully, but these errors were encountered: