WooCommerce allows you to sell all kind of products.

My favourites are the downloadable or e-products. By e-products I mean products such as ebooks, reports, software. E-products are great because you don’t have to ship anything physical and they allow for instant download / delivery.

When you add the product to WooCommerce you can set some limits e.g. how many times a product can be downloaded and when the download will expire.

After a user has reached their download limits (or the download has expired) WooCommerce will block the access to that file. This is a good safely measure because that way people won’t be able to share the download link with other people.

 

What to do when your Virtual/Downloadable products have changed?

Let’s say you want to send a mass email to let your customers know that you have a new version of your e-product. This could be because you’ve created a 2nd edition of your ebook, report or fixed some glitches in the software. Whatever the reason you want people to be able to access the files again regardless of how many times they have downloaded the file(s) in the past.

 

How WooCommerce manages the downloadable products’ limits

As with anything in life there are many ways to get the job done.

Let’s first cover how WooCommerce manages the download limits for downloadable products.  WooCommerce keeps track of the limits in a custom table called: YOUR_DB_TABLE_PREFIX_woocommerce_downloadable_product_permissions which links the order, product, and user together. After each download WooCommerce will decrease the downloads_remaining field. After it reaches 0, no more downloads will be allowed for that user and that product.

 

CREATE TABLE IF NOT EXISTS `default_db_wp_woocommerce_downloadable_product_permissions` (
  `download_id` varchar(32) NOT NULL,
  `product_id` bigint(20) unsigned NOT NULL,
  `order_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `order_key` varchar(200) NOT NULL,
  `user_email` varchar(200) NOT NULL,
  `user_id` bigint(20) unsigned DEFAULT NULL,
  `downloads_remaining` varchar(9) DEFAULT NULL,
  `access_granted` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `access_expires` datetime DEFAULT NULL,
  `download_count` bigint(20) unsigned NOT NULL DEFAULT '0',
  `permission_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`permission_id`),
  KEY `download_order_product` (`download_id`,`order_id`,`product_id`),
  KEY `download_order_key_product` (`product_id`,`order_id`,`order_key`,`download_id`),
  KEY `order_id` (`order_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

In order to reset the download limits we need to modify downloads_remaining & access_expires fields.

 

To reset the download limits for all products and all users you need to execute this SQL command in phpMyAdmin

UPDATE `default_db_wp_woocommerce_downloadable_product_permissions` SET downloads_remaining = 5, access_expires = DATE_ADD(NOW(), INTERVAL 7 DAY)

 

To reset the download limits for a selected product you need to execute this SQL command in phpMyAdmin

UPDATE `default_db_wp_woocommerce_downloadable_product_permissions` SET downloads_remaining = 5, access_expires = DATE_ADD(NOW(), INTERVAL 7 DAY) WHERE product_id = 123

To reset the download limits for a selected user ID you need to execute this SQL command in phpMyAdmin

UPDATE `default_db_wp_woocommerce_downloadable_product_permissions` SET downloads_remaining = 5, access_expires = DATE_ADD(NOW(), INTERVAL 7 DAY) WHERE user_id = 123

 

Note:

Make sure you replace "default_db_wp_" with your database table prefix which can be found in wp-config.php

Is there a better way? Yes. We have a premium plugin that can help you reset the downloadable products' limits with a click of a button. Check Orbisius Reset Download Limits for WooCommerce out

Related