WooCommerce has a pretty fantastic admin user interface. There's just enough tabs to only show you the data you need to see and have the rest of the data be easily accessible. If you're just editing one product it should be easy to change something as simple as the “download expiration” field. But what happens if you need to bulk edit products? Could you use the WordPress bulk editor?
The default WordPress bulk editor is great for a handful of products. But what if your company has some sort of policy change? Like one that changes how long all of your links are valid. If that's the case you could easily be editing all of the products in your store. That's where it helps to know a little code and just update the database directly.
SQL to the Rescue
I wrote a short little SQL statement that you can execute through phpMyAdmin. It will go through all of your products and change their download expiration date fields. This will affect all future purchases of those products. The snippet automatically changes the expiration date to 7 but you can change that 7 to any number you want. Just make sure to update the wp_postmeta
table with your own table prefix set in your wp-config.php
file.
What About Past Orders?
If you want to change the download expiration date for products that are already purchased you'll have to do some additional work in the database. You'll have to update the access_expires
in the wp_woocommerce_downloadable_product_permissions
table.
Blogging for Benjamin
This is the fourth post for the Blogging for Benjamin contest. If you have certain topics that you'd like for me to discuss please list them in the comments. I'll have all of December to fill up with blog posts. 🙂