wcfm-santa

REPUBLIC DAY SALE! Upto 30% off

CLAIM OFFER

Cancel payment of subscription but not subscription

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WC Subscriptions Cancel payment of subscription but not subscription

This topic contains 1 reply, has 1 voice, and was last updated by Avatar defaperacm 1 week, 4 days ago.

  • Author
    Posts
  • #101953
    Avatar
    defaperacm
    Participant

    Hi.
    I have a “premium” subscription wich have to be payed monthly. the case is if one user doasn’t pays the subscription, the plugin assigns to it the “disabled vendor” profile.

    Olso une user told to me the other day that when trying to cancel the susbcription payment for the next month. his subscription was cancelled.

    how can i fix it?
    ani shortcodes or hooks will be appreciated.

  • #101955
    Avatar
    defaperacm
    Participant

    first issue solved with this code (just add tho functions.php in custom theme):

    $cancelled = false;
    function on_cancelled_subscription($user_id) {
    	if (!$cancelled) {
    		update_user_meta( $user_id, '_disable_vendor', false );
    		$user = get_user_by( 'id', $user_id );
    		$user->set_role( 'wcfm_vendor' );
    	}
    	$cancelled = true;
    }
    add_action('wcfm_membership_data_reset', 'on_cancelled_subscription');

    $cancelled flag is used because the action ‘on_cancelled_subscription’ may be called more tha one time, so it prevents from spamming the database

    this code was made by ┬┐reverse-engineered? the file class-wcfmvm.php

You must be logged in to reply to this topic.