Hi @antibalashifi,
Once a product is permanently deleted its data is removed from the database including the Product ID. You can try to recover the ID from Analytics > Products.

Link to image: https://i.imgur.com/WhW2UTp.png
If that doesn’t work for you, you may need to restore a backup copy previous to the product deletion. I hope you’re holding a backup, otherwise, you can ask your host that should’ve saved one. Restore the backup on a staging site and get the Product ID.
Best.
Thread Starter
DataLife
(@antibalashifi)
Thank you for this trick!
I keep daily backups for 30 days, but the deletion happened several years ago.
Trying your method, I discovered the product was actually deleted at two different times. Luckily, the version with 99% of the orders was recovered: product_id 1408. The other only had 2 orders, and the product_id was 0…?
How can I change both of these product_ids to the new product_id? With some direction I’m comfortable going into phpMyAdmin, although I have little experience there.
-
This reply was modified 1 year, 4 months ago by
DataLife.
Plugin Support
con a11n
(@conschneider)
Engineer
Hi again,
Since it is historic data I would do the following:
* Take a backup.
* Block all mails with something like: https://wordpress.org/plugins/disable-emails/
* Edit the old order and set it to pending payment, add your recovered item, set it back to processing / completed – screencast: https://a.cl.ly/ApuXdzKq
* allow all mails again.
Would that work for you?
Kind regards,
Thread Starter
DataLife
(@antibalashifi)
Thank you for this video. There are 700 orders with this issue, so unfortunately I’d need a more batch-able solution.
Thanks for the hot tip on the email blocker — I may need something like that, although I use Amazon SES for sending emails, not sure if this blocks those too?
Thread Starter
DataLife
(@antibalashifi)
I saw this suggestion somewhere, would it work?
Run this SQL script:
update wp_woocommerce_order_itemmeta
set meta_value = 'new_product_id'
where meta_key = '_product_id' and meta_value = 'old_product_id'