Enable only one purchase per subscription in all store
-
Is there a way to block logged in user from buy any product after the first purchase of any product?
I want to limit each subscription to buy only one product and then no more shops on any product, only with new subscription.
I found a filter that do almost what i need but limit only one per product,
add_filter('woocommerce_add_to_cart_validation','rei_woocommerce_add_to_cart_validation',20, 2); function rei_woocommerce_add_to_cart_validation($valid, $product_id){ $current_user = wp_get_current_user(); if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id)) { wc_add_notice( __( 'Purchased', 'woocommerce' ), 'error' ); $valid = false; } return $valid; }
but i need to lock every other product after first purchase of a subscription.
Maybe the best way would be when user click to pay for the product at check out page (at this time he need to be logged in) and check if he already purchased any product before.. if yes, he cant pay, only with new subscription…
im ugly on coding.. could somebody help me with this???
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Enable only one purchase per subscription in all store’ is closed to new replies.