Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
87 stars 33 forks source link

End of the Month Subscription Issue for February 27, 2023 @ 11:00 pm #422

Open TimBHowe opened 1 year ago

TimBHowe commented 1 year ago

Describe the bug

Have a site where we are using subscriptions to set up payment plans, and while this isn't what it was inteded for it was the best option at the time.

We have a scenario that popped up where there is a variable subscription product with options of "Pay in Full" or Pay over 3 months"

The Pay in Full is a set to be the full amount paid every month but set to expire in 1 month

  1. The customer originally purchased the Pay in Full on February 27, 2023 @ 11:00 pm EST

  2. ​That product was set correctly to pay $X.xx every month, but is also set to expire after 1 month.

  3. ​​The renewal order happened on March 28, 2023 @ 12:05 am EDT (daylight savings was on March 12, 2023)​​

  4. ​The subscription is set to expire March 30, 2023 @ 11:59 pm EDT (the end of the month) ​

The issue appears to be with the WooCommerce Subscription plugin and how in this case it calculated when the subscription expires vs. schedules the renewal action https://woocommerce.com/document/subscriptions/faq/#section-17

To Reproduce

  1. Create a subscription product that is $X.xx paid every month and expires in one month
  2. Set you server/site time to be February 27, 2023 @ 11:00 pm when you purchase it
  3. Review the Parent Order, Subscription, and Scheduled Action for the Renewal

Expected behavior

Expected the subscription's expiration date and renewal to be the same causing the expiration to end and not renew

Actual behavior

The subscription renewed 2 days prior to it being set to expire charging the customer again.

Product impact

Additional context

This seems like an edge case scenario, but the logic in setting the expiration date and scheduling the action for renewal seem to not be calculated the same.

sharmashivanand commented 1 year ago

We think we have the same bug and trying to debug this for weeks now.

Environment: WP: 6.1.1 / 6.2 Plugins: woocommerce-subscriptions 5.0.1 woocommerce 7.5.1 tutor 2.1.8 tutor-pro 2.1.8 order-status-control-for-woocommerce 1.0.1

It's a complex setup with buddyboss, elementor however it worked fine so far.

To debug, we have a subscription set to renew every day for a tutor test course.

Renewal happens. The Tutor enrollment happens (verified in database via PHPMyAdmin) and then instantly it expires.

Happy to follow any steps or provide further info.

moneythumb commented 1 year ago

We have what seems like the same issue. A customer subscription for a variable subscription product was renewing on the 27th of each month at about 7:55 PM Pacific time. The subscription started in January 2022, and everything was fine up until March 2023 when the subscription renewed on both March 27th and March 30th, and then also renewed on both the 27th and the 30th in April, May and June.

I am thinking that it has something to do with the renewal time in UTC being on the last day of the month. Seems like a pretty nasty problem that ought to be addressed.

Woocommerce 7.4.1, Woocommerce subscriptions 4.91, and we do run elementor.

Also, in order to fix this subscription going forward, I believe a (the?) solution is to edit the "_subscription_renewal_order_ids_cache" field in "wp_postmeta" table to remove the superfluous renewals. I can confirm that one way or the other at the end of July.

matt-h commented 11 months ago

@mattallan Can this be re-opened? It looks like it closed from #474 but it looks like #474 should have targeted issue #448 and not this issue.

We just had other instance of this bug.

Order placed September 29, 2023 11:23 pm Renewal set to October 29, 2023 11:23 pm End Date set to October 30, 2023 11:23 pm

End date should have been the 29th not the 30th.

mattallan commented 11 months ago

Good catch @matt-h, I'll re-open this one

MattMoneyThumb commented 10 months ago

Hi @mattallan,

We have had multiple instances of this bug for months and ran into the same issues as @matt-h at the end of September and October. We're watching to see if it happens again at the end of November.

Can this be moved to a higher priority?

Thanks!