kingtommy dot com

MeetCritique one membership per account

Client project · Excerpts from the live MeetCritique code

A member was once billed twice a month. This guard stops a second FullSend subscription from being bought while the first is live.

WooCommerce Subscriptions has a limit setting, but it is per product, so a monthly member could still buy the annual plan. This check is per membership: any product carrying fullsend_months counts. It filters woocommerce_subscription_is_purchasable at priority 20, after the plugin's own limiter at 12, and only ever turns true into false.

Renewal, resubscribe, switch and pay-for-order requests are exempt. WooCommerce Subscriptions empties the cart before re-adding a renewal, so the code reads the request URL to recognize them. Blocking them would strand a member whose payment failed.

Two more layers back this one up: add-to-cart validation with a clear message, and a cart check that covers block checkout and express pay.

The purchasable filter functions.php:3713-3718, 3728-3729, 3735-3738
// Priority 20 = after WCS_Limiter's own filters at 12. Only ever turns a
// true into a false.
add_filter( 'woocommerce_subscription_is_purchasable',           'mc_fullsend_block_duplicate_purchase', 20, 2 );
add_filter( 'woocommerce_subscription_variation_is_purchasable', 'mc_fullsend_block_duplicate_purchase', 20, 2 );
function mc_fullsend_block_duplicate_purchase( $purchasable, $product ) {
    if ( ! $purchasable ) return $purchasable;
// …
if ( ! mc_fullsend_is_membership_product( $product ) ) return $purchasable;
if ( ! mc_fullsend_user_live_subscription( $user_id ) ) return $purchasable;
// …
    if ( mc_fullsend_is_existing_subscription_flow() ) return $purchasable;

    return false;
}

All demos