easy-digital-downloads icon indicating copy to clipboard operation
easy-digital-downloads copied to clipboard

Throw an "Are you sure" when deleting a product that has sales.

Open mintplugins opened this issue 7 years ago • 10 comments

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?

mintplugins avatar Jan 16 '18 17:01 mintplugins

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): screen shot 2018-01-16 at 10 30 52 pm

cklosowski avatar Jan 17 '18 05:01 cklosowski

I wouldn't mind looking at sorting this.

rwebster85 avatar Jan 26 '18 17:01 rwebster85

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 avatar Jan 26 '18 18:01 rwebster85

@rwebster85 were you still interested in submitting a PR for this?

SeanTOSCD avatar Mar 31 '18 20:03 SeanTOSCD

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 avatar May 14 '18 20:05 mintplugins

@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.

cklosowski avatar Sep 05 '18 06:09 cklosowski

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.

rwebster85 avatar Jun 01 '21 13:06 rwebster85

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.

spencerfinnell avatar Jun 01 '21 14:06 spencerfinnell

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.

cklosowski avatar Jun 01 '21 21:06 cklosowski

In 3.0 Discounts and Tax Rates use "Deactivate" and become "Inactive", which would also work for Products.

spencerfinnell avatar Jun 02 '21 12:06 spencerfinnell