mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-30 11:42:22 +08:00
https://github.com/easydigitaldownloads/library/blob/master/_checkout/prevent-duplicate-purchases.html
10 lines
426 B
Text
10 lines
426 B
Text
function pw_edd_prevent_duplicate_purchase( $valid_data, $posted ) {
|
|
|
|
$cart_contents = edd_get_cart_contents();
|
|
foreach( $cart_contents as $item ) {
|
|
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' );
|
|
}
|
|
}
|
|
}
|
|
add_action( 'edd_checkout_error_checks', 'pw_edd_prevent_duplicate_purchase', 10, 2 );
|