Woocommerce digital download not working – database error Cannot add or update a child row: a foreign key constraint fails

I’m having an issue when trying to download a digital product from Woocommerce. When clicking the download link/button on thank you page or woocommerce email, the link shows an error.

After going to the PHP Error logs I found this:
WordPress database error Cannot add or update a child row: a foreign key constraint fails. CONSTRAINT fk_wc_download_log_permission_id FOREIGN KEY (permission_id)

REFERENCES wpdev_woocommerce_downloadable_product_permissions (permission_id) for query INSERT INTOwp01_wc_download_log`

How can I solve this?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Just go to your database, drop table ending with “wc_download_log” (it might have a prefix).
After droping the table deactivate Woocommerce and activate it again.

That will solve the trick. Just be careful, drop just that table, be sure to back things up first.

This post helped me solved this: https://wordpress.org/support/topic/unable-to-insert-download-log-entry-in-database/page/2/#post-13359528


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x