Skip to content

Instantly share code, notes, and snippets.

@anandkumar
Created January 29, 2014 15:21
Show Gist options
  • Save anandkumar/8690178 to your computer and use it in GitHub Desktop.
Save anandkumar/8690178 to your computer and use it in GitHub Desktop.
EDD Prevent Double Purchase
<?php
// EDD Prevent Double Purchase
function pw_edd_prevent_double_purchase( $valid_data, $post_data ) {
$cart_items = edd_get_cart_contents();
foreach( $cart_items as $item ) {
if( edd_has_user_purchased( get_current_user_id(), $item['id'] ) ) {
edd_set_error( 'double_purchase', __( 'You may not purchase this item again until your subscription expires', 'edd' ) );
}
}
}
add_action( 'edd_checkout_error_checks', 'pw_edd_prevent_double_purchase', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment