When a user is deleted all subscriptions for that user should be unsubscribed first.
Thanks Luke. In addition to it being impossible to delete users with subscriptions, It looks like there's also no way of deleting subscriptions in the control panel, so we're stuck with lots of garbage test data and users.
Is the bug related to deleting users, mentioned by @thisisjamessmith above, going to addressed as a part of this issue.
being impossible to delete users with subscriptions
We are still running into it with both active and inactive / expired subscriptions on 3.0.11
Issue still persist even when unsubscribed from subscription. FK plugin didn't help also.
Steps to reproduce
Fresh installation of: Craft, Commerce Lite, Stripe for Craft Commerce
Setup stripe.com and create subscriptions.
Create subscriptions in CP
Create a custom registration form: https://docs.craftcms.com/v3/dev/examples/user-registration-form.html#app
Register through form and activate account.
Browse to default shop/services and purchase a subscription.
Go to manage your subscription and end immediately.
Go to CP as admin and try to delete that user.
Note that may help:
I try to delete the former subscribed user in database table "elements" and am prompt with:
"#1451 - Cannot delete or update a parent row: a foreign key constraint fails (mydbname.commerce_subscriptions, CONSTRAINT commerce_subscriptions_userId_fk FOREIGN KEY (userId) REFERENCES users (id))"
Also having this issue, as per the 'steps to reproduce' report from @Dev2637
yep same issue. unable to delete 9 users whose subscriptions were canceled..what am I supposed to do?
yep same issue. unable to delete 9 users whose subscriptions were canceled..what am I supposed to do?
Wait for a fix ;)
There's probably a data integrity issue, whereby the subscription records require a user to exist. Hopefully there will be a way to simply anonymise subscriptions when the linked user is deleted!
Sorry to just bump this ticket, but we got a lot of test users+subscriptions in our system that we would like to get rid of. Any chance there has been an update on this issue or maybe someone found a workaround for the time being?
Any news?
We added the php craft commerce/reset-data command that removes all orders, subscriptions, payment sources, customers, addresses and reset discount usages.
This is useful before moving to production for the first time only and removing all test data.
As for deleting a user in production who only has a cancelled subscription, we need to talk more internally about handling this case, especially with subscription syncing coming to the stripe plugin. Stay tuned. Feel free to express what your preferences/needs would be.