• Resolved christophmuth

    (@christophmuth)


    Hi,

    I’d like to know if there is a possibility to change subscriptions under my account. This means that in addition to the “Cancel” and “Change Payment Method” buttons, there is another change option.

    Regards

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Payment Plugins

    (@mrclayton)

    Hi @christophmuth

    Are you using the plugins subscription functionality or WooCommerce Subscriptions?

    If using the plugin’s built in subscription functionality you can do the following:

    Hook in to filter bfwc_subscription_user_actions which should include two objects; the array of actions and the subscription object. The filter is called in the bfwc_subscription_user_actions function located in braintree-bfwc-functions.php.

    function bfwc_subscription_user_actions( $subscription )
    {
    	$actions = array ();
    	if ( $subscription->has_status( 'active' ) || $subscription->has_status( 'past-due' ) ) {
    		$actions [ 'cancel' ] = array (
    				'label' => __( 'Cancel', 'braintree-payments' ), 
    				'url' => add_query_arg( 'cancel-subscription', $subscription->id, wp_nonce_url( wc_get_endpoint_url( 'view-subscription', $subscription->id, wc_get_page_permalink( 'myaccount' ) ), 'cancel-subscription' ) ) 
    		);
    		$actions [ 'change_payment_method' ] = array (
    				'label' => __( 'Change Payment Method', 'braintree-payments' ), 
    				'url' => wc_get_endpoint_url( 'change-payment-method', $subscription->id, wc_get_page_permalink( 'myaccount' ) ) 
    		);
    	} elseif ( $subscription->has_status( 'pending' ) ) {
    		$actions [ 'pay_for_subscription' ] = array (
    				'label' => __( 'Pay', 'braintree-payments' ), 
    				'url' => $subscription->get_checkout_payment_url() 
    		);
    	}
    	return apply_filters( 'bfwc_subscription_user_actions', $actions, $subscription );
    }

    If you are using WCS they have documentation on how to add actions to the subscription. That process is similar to what I have described above.

    Kind Regards,

    Thread Starter christophmuth

    (@christophmuth)

    Hi @mrclayton,

    thanks for your response.
    I am using the built in subscription functionality and connected my product variants with Braintree. I already managed to add the button for updating the subscription options, but i’m not sure which endpoint_url I have to use therefor (“change-subscription-plan” is not working):

    
    $actions [ 'update' ] = array (
                'label' => __( 'Update subscription', 'braintree-payments' ),
                'url' => wc_get_endpoint_url( 'change-subscription-plan', $subscription->id, wc_get_page_permalink( 'myaccount' ) )
    );
    

    I want to redirect the user to the product page and update the subscription on save. Is this possible?

    • This reply was modified 6 years, 9 months ago by christophmuth.
    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @christophmuth,

    Upgrading the subscription using the plugin’s basic subscirption functionality is not possible at this time. We may look at adding that feature in the future though.

    Adding an endpoint like “change-subscription-plan” would only work if you had some functionality already built to use the endpoint.

    The plugin provides all of the necessary actions and filters for you to add this functionality should you choose to add custom development.

    Kind Regards,

    Thread Starter christophmuth

    (@christophmuth)

    Ok, thank you for your advice ??

    Thread Starter christophmuth

    (@christophmuth)

    Hi @myclayton,

    can you give me some advice where to start when I want to implement the change-subscription-plan functionality?

    Kind Regards

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Update Subscription Plan’ is closed to new replies.