You have created with your own hands or with the help of one or more providers a site under WooCommerce allowing you to sell digital items, thus downloadable for your customers.
The shop is in place, the files available for download are uploaded on the server, the product sheets are created, the customer area and the payment are set up and operational… in short everything is ready, but a problem occurs at a specific point in your purchasing process.
A customer connects to his account to place an order for a downloadable product. He makes the payment. Everything went well, his payment is accepted, he finds the product he bought for download in his customer area, but when he clicks on it to retrieve it, the following error message appears:
Unable to insert download log entry in database
Note that in the base and in the administration the order is well registered. So the whole purchasing process went well. It is probably a problem directly related to the recovery of the purchased file.
WooCommerce uses, like WordPress, the database to insert and access many useful data. The error is quite explicit, it is a problem in your database.
We will look at the wc_download_log table. It is indeed this one in particular which is in question. Notably, because we need to see if it is the only problem in your database.
First, connect to your database and find out if the wc_download_log table exists.
If it doesn’t exist, you’ll have to create it. The easiest way to create it, is to go to your WordPress administration, disable then enable the WooCommerce extension.
To do this, look for the menu “Plugins” in the left part of your administration. You should be able to find the WooCommerce extension. You just have to deactivate then reactivate the extension.
Otherwise, an alternative can be to create the table “by hand“. Here is an example of SQL script to create it :
CREATE TABLE `wc_download_log` (
`download_log_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`timestamp` datetime NOT NULL,
`permission_id` bigint(20) unsigned NOT NULL,
`user_id` bigint(20) unsigned DEFAULT NULL,
`user_ip_address` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT '',
PRIMARY KEY (`download_log_id`),
KEY `permission_id` (`permission_id`),
KEY `timestamp` (`timestamp`),
CONSTRAINT `fk_wc_download_log_permission_id` FOREIGN KEY (`permission_id`) REFERENCES
`woocommerce_downloadable_product_permissions` (`permission_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
You will need to get the right version of this script for your version of WooCommerce, as there may be structural differences from one version to another.
If the table is not created, you will have to check the rights on your database. But if the other tables are present (otherwise you will encounter other errors), it should work.
Of course, you will have to ask yourself how this problem could have occurred, and, if necessary, make an audit of your installation to see if everything is compliant, especially security level.
Still stuck ? You can contact an expert.