Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
81 stars 29 forks source link

Allow admin users to turn on automatic renewals if the subscription has a saved payment method #535

Closed james-allan closed 8 months ago

james-allan commented 8 months ago

Fixes https://github.com/woocommerce/woocommerce-subscriptions/issues/4094 Fixes https://github.com/Automattic/woocommerce-subscriptions-core/issues/519

Description

There's a feature in Woo Subscriptions that enables customers to switch between automatic and manual renewals. This is known as the auto renewal toggle.

Auto-renewals off Auto-renewals on
Screenshot 2023-10-31 at 12 40 39 pm Screenshot 2023-10-31 at 12 41 08 pm

When a customer turns off automatic renewals in this way, admin users are unable to switch it back to automatic renewals. This is because this toggle sets the _requires_manual_renewal flag which there's is no UI element for.

This PR fixes that by adding a new checkbox on the edit subscription screen to allow them to turn automatic renewals back on.

https://github.com/Automattic/woocommerce-subscriptions-core/assets/8490476/c4e2cea8-8d5b-4f27-9a9f-c570b964a9c7

The new "Auto renew" checkbox

How to test this PR

  1. Make sure you have Woo Subscriptions installed.
  2. Install this version of subscriptions-core (reminder: you can clone this repo and treat it like a plugin).
  3. Go to WooCommerce β†’ Settings β†’ Subscriptions
  4. Make sure the Auto Renewal Toggle setting is on.
  5. Purchase a subscription using WooPayments, Stripe or any automatic payment method.
  6. Go to the My Account View Subscription page.
  7. Click the Auto renewal toggle.
  8. As admin go to WooCommerce β†’ Subscriptions and edit the subscription.
    1. On trunk you'll notice that there's nothing you can do to turn automatic payments back on. Editing the billing details, doesn't enable you to set the auto renewal flag.
    2. On this branch, you'll notice two things.
      1. There are Subscription notes now added when the customer toggles auto renewal.
      2. If you edit the billing details, you will see a checkbox enabling you to turn on automatic renewals. (see video example above).

Screenshot 2023-10-31 at 1 20 14 pm
Subscription notes

Product impact

james-allan commented 8 months ago

after changing the toggle from My account page, the payment method can not be changed from Edit subscription page by admin

The payment method can be changed from the edit subscription page after using the toggle from the my account page. My understanding of that part was that it can be changed but not saved. I've included a video of what I believe they were referring to below.

https://github.com/Automattic/woocommerce-subscriptions-core/assets/8490476/448a43a5-19cc-4eb3-9600-fd0e75fa944d

The reason changing the payment method in this video isn't "sticking" is because the subscription has the "requires manual renewal" flag set which means irrespective of the payment method, it is locked to manual renewals.

Adding this checkbox allows the user to turn off that manual renewal lock and therefore resume automatic renewals and for the chosen payment method to take effect.

Another approach we could look into is something like this:

  1. The payment method dropdown is set to manual renewal if the requires manual renewal flag is on.
  2. If admin change the payment method and save, we assume they intend on turning on automatic renewals and so switch it to automatic renewals.

I'm trying to think if that would break any flows, making an assumption like that. What do you think though @mayisha, would that make more sense rather than a checkbox?

james-allan commented 8 months ago

What do you think though @Mayisha, would that make more sense rather than a checkbox?

I've been having a go at implementing this and I think this makes a lot more sense than the checkbox.

https://github.com/Automattic/woocommerce-subscriptions-core/assets/8490476/1f332784-f039-4d8e-98fe-2da69138776b

I think this is inline with what you were suggesting right?

Mayisha commented 8 months ago

Sorry for not elaborating on my question before :no_mouth:

This implementation https://github.com/Automattic/woocommerce-subscriptions-core/pull/535#issuecomment-1791853080 exactly aligns with what I meant. :100: