easy-digital-downloads
easy-digital-downloads copied to clipboard
Throw an "Are you sure" when deleting a product that has sales.
Deleting a product that has sales can cause problems with reporting, and with customers.
If a store owner is deleting a product, could we throw an "Are you sure" message that warns them it could throw off their reporting, and that they should make it a draft
instead of deleted it?
I feel like we could use the same 'modal' type system that is in place when you go to edit a post
when someone else is editing.
Example (just a quick Proof of Concept):
I wouldn't mind looking at sorting this.
For reference that dialog box is part of the Heartbeat API and this is the function that displays it: https://developer.wordpress.org/reference/functions/_admin_notice_post_locked/
@rwebster85 were you still interested in submitting a PR for this?
Just to note, this should also apply to deleting a variable price, as deleting a variable price is essentially the same as deleting a product. We would have to introduce some sort of drafting system for variable prices to make that possible though.
To keep it simple we could just throw the warning.
@mintplugins on the note of 'variable pricing' I think we should allow deleting if there are no sales, but along with awesomemotive/easy-digital-downloads-pro#35 we could simply swap a 'remove' icon to a 'disable' when a variable price ID has sales.
In all respects 3.0 will make this a far more performant query than we currently have for this.
Just coming back to this one. In my opinion in order to maintain referential integrity it might be better to prevent a product that has sales from being deleted. Maybe put them in a separate post status that behaves like private in some way.
I like the idea of an "Archived" status. Stripe uses the same terminology for the same reason -- "disabling" a Product, Tax Rate, etc that needs to continue to exist but it not being actively used.
Archived
seems interesting to pursue. With the idea in 3.0 of having the immutable concept, this would be inline with those types of decisions and concepts.
In 3.0 Discounts and Tax Rates use "Deactivate" and become "Inactive", which would also work for Products.