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
Was requested by a customer that if the user has an active subscription for Download X he should not be allowed to buy it again.
Code that seems to work:
function pw_edd_recurring_limit_one_subscription( $valid_data, $post_data ) {
if( ! is_user_logged_in() ) {
return;
}
$subscriber = new EDD_Recurring_Subscriber( get_current_user_id(), true );
$cart_contents = edd_get_cart_contents();
foreach( $cart_contents as $item ) {
if( $subscriber->has_active_product_subscription( $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_recurring_limit_one_subscription', 10, 2 );
The text was updated successfully, but these errors were encountered:
Was requested by a customer that if the user has an active subscription for Download X he should not be allowed to buy it again.
Code that seems to work:
The text was updated successfully, but these errors were encountered: