Update Subscription Plan
-
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
-
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_actionswhich should include two objects; the array of actions and the subscription object. The filter is called in thebfwc_subscription_user_actionsfunction located inbraintree-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,
-
This reply was modified 8 years, 3 months ago by
Clayton R.
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 8 years, 3 months ago by
christophmuth.
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,
Ok, thank you for your advice 🙂
Hi @myclayton,
can you give me some advice where to start when I want to implement the change-subscription-plan functionality?
Kind Regards
-
This reply was modified 8 years, 3 months ago by
The topic ‘Update Subscription Plan’ is closed to new replies.