Created
January 29, 2014 15:21
-
-
Save anandkumar/8690178 to your computer and use it in GitHub Desktop.
EDD Prevent Double Purchase
This file contains hidden or 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 | |
// 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