If you are selling WordPress themes or plugins, one of the number one things you should absolutely consider implementing into your products is automatic upgrades. If avoidable, there is no reason a user should be forced to manually log into your site and download a new version, then log into their own site and upload the new version. WordPress provides a full API for offering automatic upgrades, even to non-repository hosted plugins, so I’d highly recommend you utilize it.
At some point I’m going to write an in-depth tutorial on how to create your own custom automatic upgrade systems, but in this post I want to show you a really easy way to sell your WordPress products, and include a license key with all purchases that can be used for receiving automatic upgrades.
If you’re not convinced that you should be providing automatic upgrades, then I suggest you read Brian Krogsgard’s post on the subject.
We are going to use my Easy Digital Downloads plugin and the Software Licensing add-on I recently released for our product store.
Easy Digital Downloads will provide the ability to sell our product, and have it available as a download immediately after purchase. It does much more than this, such as sales and revenue tracking, but simply selling the digital product is what we need for this walk through.
The Software Licensing add-on extends the functionality of Easy Digital Downloads to include the ability to generate a license key at the time of purchase. This license key is then used to verify the customer’s purchase and provide automatic upgrades to users with a valid license key. It’s a nice way to reward your loyal customers (who have actually purchased the item), while not directly limiting the functionality of the system.
To see an overview of how the licensing system works, watch the video below:
Software Licensing is an $82 add-on for EDD, but the price is pretty minimal when you think about how much it improves your business model. Also, if you use the following discount code, you can save 20%: AUTOUPGRADES
Overview of How the System Works
In terms of setting it up, the system is really quite simple. The products are sold through Easy Digital Downloads, Software Licensing creates a license key, this license key is then entered into the settings of the plugin or theme the customer has purchased, and then a small code snippet (provided by Software Licensing) is added to the plugin or theme that takes care of checking when updates are available.
The most up-to-date version of the plugin or theme, is the one that is hosted in your EDD store, which is also where the latest version number and change log is defined.
When a customer has a valid and active license key, their site (running the plugin or theme) or send a remote request to your store (running EDD) to check if there is a new version available. The version check, however, will only run if it also detects that the customer has provided an active license key. If the customer’s key is invalid, or expired, they will not receive any update notifications.
When a customer is alerted of a new update being available, the notification for the update will show up in their WordPress dashboard just like any other WP theme or plugin. All of UI elements are 100% provided by WordPress core.
After clicking “Install Update”, the customer’s WordPress site will remotely, and securely, download the latest version of the plugin or theme from your Easy Digital Downloads store.
It’s all seamless.
Step 1 – Setup Your Product in Easy Digital Downloads
The product configuration for EDD is quite simple. You first go to Downloads > Add New, enter a title and description (just like a regular WordPress post), and then configure teh product-specific details, as shown in the image below:
How you configure your product really does not affect the automatic upgrades, except for one key element: the download files. You must setup at least one of the download files to be a plain .zip file of the theme or plugin that only has the files of the plugin or theme contained within.
Step 2 – Enable License Key Generation and Configure Upgrade Files
Only those products that have been specified as having license key generation enabled will create a license key when purchased. This means that you can enable licensing for some products, while leaving it turned off for others.
When Software Licensing is activated, you will have a new meta box added to your Download page called “Licensing”. Check the box to enable license creation, enter the latest version number, and select the download file that should be served as the upgrade file when users update. Note, you must click update your product after adding the download files before they will show up in this drop down.
After you have enabled license creation, entered the version number, and selected the upgrade files, you will want to enter the change log info in the box labeled “Change Log”. This is the information the customer will see when upgrading their products.
Add the Updater Code to Your Plugin or Theme
The Software Licensing add-on comes with everything you need to implement the automatic updater into your WordPress products, and this includes almost-ready-to-use code snippets. All you have to do is adjust the code snippets to match your particular product and store website. The basic code looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | // this is the URL our updater / license checker pings. This should be the URL of the site with EDD installed define( 'EDD_SL_STORE_URL', 'http://yoursite.com' ); // you should use your own CONSTANT name, and be sure to replace it throughout this file // the name of your product. This should match the download name in EDD exactly define( 'EDD_SL_ITEM_NAME', 'Sample Plugin' ); // you should use your own CONSTANT name, and be sure to replace it throughout this file if( !class_exists( 'EDD_SL_Plugin_Updater' ) ) { // load our custom updater include( dirname( __FILE__ ) . '/EDD_SL_Plugin_Updater.php' ); } // retrieve our license key from the DB $license_key = trim( get_option( 'edd_sample_license_key' ) ); // setup the updater $edd_updater = new EDD_SL_Plugin_Updater( EDD_SL_STORE_URL, __FILE__, array( 'version' => '1.0', // current version number 'license' => $license_key, // license key (used get_option above to retrieve from DB) 'item_name' => EDD_SL_ITEM_NAME, // name of this plugin 'author' => 'Pippin Williamson' // author of this plugin ) ); |
There is also a second code snippet that is used for activating a license key remotely (remember, updates are only delivered to customers who have activated their license keys):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | function pw_edd_sl_activate_license() { global $edd_options; if( !isset( $_POST['your_activation_button'] ) ) return; if( get_option( 'pw_edd_sl_license_active' ) == 'active' ) return; $license = sanitize_text_field( $_POST['edd_settings_misc']['edd_sl_license_key'] ); // data to send in our API request $api_params = array( 'edd_action'=> 'activate_license', 'license' => $license, 'item_name' => urlencode( EDD_SL_PLUGIN_NAME ) // the name of our product in EDD ); // Call the custom API. $response = wp_remote_get( add_query_arg( $api_params, EDD_SL_STORE_API_URL ) ); // make sure the response came back okay if ( is_wp_error( $response ) ) return false; // decode the license data $license_data = json_decode( wp_remote_retrieve_body( $response ) ); update_option( 'pw_edd_sl_license_active', $license_data->license ); } add_action( 'admin_init', 'pw_edd_sl_activate_license' ); |
I have written extensive documentation that fully explains the code implementation:
Automatic Upgrade Integration for Plugins
That’s it! You now have a fully functional automatic upgrade system for your WordPress products that gives your customers the same seamless experience they’re used to with WordPress. It also gives you a seamless system for sending out updates to your products.
And now that I have purchase this masterpiece it’s time to start testing and play around with it.
By the way, it took me awhile to find where I put my license key to get auto updates. I’m sure you have document that, but I just didn’t see that. It was under Downloads >> Settings >> Misc in case someone else is wondering the same thing.
One question. When I use Software Licensing Plugin in my localhost and set up live site later, I probably need to deactive Plugin in localhost. I can’t have auto updates in two places, or can I?
The license key option is documented in the documentation.
Actually yes, you can have automatic updates in two places. It won’t cause any problems.
Okay, thanks again. Docs are as good as your Plugins.
Thanks! That’s something I like to hear!
This sounds like a fantastic plugin! One question: Do you have to use easy digital downloads in order to use the Software License key generator plugin? Or can we use that as a standalone feature in a plugin and sell via another marketplace (possibly external, not just on a personal site)?
Thanks Tom! It requires Easy Digital Downloads as it is an add-on that extends EDD to provide the licensing and upgrade features.
Hey Pippin,
We’re looking at adding auto-updating to our new premium plugins and themes, and I’d like to ask a few questions about this add-on. We currently aren’t using Easy Digital Downloads, so if I ask a silly question, please forgive me.
Instead of creating zip files for every new release, we are currently moving over to an SVN to dynamic ZIP creation model. This saves time on our parts because we don’t have to manually zip the files or remove directories, files, etc. that shouldn’t be in the zip. Would it be possible to hack this plugin so that the newest version number and changelog are pulled from the SVN automatically instead of entering them manually as you show in the video? (Of course, I already know how to pull that data from the SVN, just curious about how flexible this plugin is.)
With the licensing plugin, is it possible to add user subscriptions manually? We are interested in doing some alpha/beta testing with our products, and I’d like to be able to add these users myself in the backend.
Thank you very much for your time, and I look forward to hearing from you.
Kevin
wpninjas.net
Kevin, it is absolutely possible to modify the plugin to pull from an SVN. There are hooks and filters in place that you can use to do exactly that. Yoast (developer of WordPress SEO) is already in the process of building an add-on that integrates with Software Licensing that lets you deliver updates from Github, including change logs and version numbers.
If you have the Manual Purchases add-on, you can easily add users/licenses manually through the backend. I use it almost everyday on EasyDigitalDownloads.com
Hi Pippin
I didn’t see the answer in the docs, but is there currently a way of limiting the serial to a set number of site installs?
i.e. serial works on ‘X’ number of sites, and if client tries to activate on an extra, they get warning about deactivating a site first?
Cool plugin btw, and Yoasts addon sounds like a great addition. I didn’t see it mentioned on his site yet, so hoping to track it down someday.
There is an option for this, though it was added as an update, which is why it’s not as well documented.
Currently it doesn’t send a warning if the limit is reached, it returns an error though and will not let the user activate the license again.
Yoast hasn’t released the add-on yet, but I’ll try and see if I can find some status updates on it.
Hi, I like your plugin and I have a simple proposal, an exchange.
I’m not as good as you in coding so I would not be of any help but I can easily translate any english text in Italian language (i’m italian).
I can exchange my translation knowledge with your plugin and addons.
What do you think about it?
As a proof of my experience you can check this: http://fiverr.com/takycardia/translate-up-to-500-words-from-french-or-english-into-italian
Sorry but I cannot offer a trade since Easy Digital Downloads has already been translated into Italian. If you would like to check the translation to ensure it is up to date, and also translate the Software Licensing extension, I can give you a nice discount though.
Have you considered a version of this that would work with Authorize.net? I’d rather not be limited by just paypal for orders.
The Software Licensing is payment gateway independent. By default, Easy Digital Downloads comes with PayPal, but there are paid extensions for other payment gateways, including Authorize.net: https://easydigitaldownloads.com/extension/authorize-net-gateway/
Thanks that looks like it would work perfectly – curious do you think that would integrate with something like Wishlist Member? I have an integrated back end membership and would if possible like to tie the two together.
One other thing can you have an order link right to order page with out going to a cart page first?
Thanks
What kind of integration with Wishlist are you looking for? In what way do you want to tie them together?
All purchases must go through the checkout process; it is required.
In the past I’ve used wishlist to protect my download pages. and thought I’d like to keep it the same way although that may not be needed.
I don’t mind going through a check out process – I just want the order button to go right to the order page and not a step in between is that possible?
Do you mean that you want the user automatically redirected to the checkout page as soon as they click “Purchase”/”Add to Cart”? Right now it adds the item to the cart and then presents a “Checkout” button. Is that the middle step you’re referring to?
That is correct – I’d rather just purchase button go right to what happens when they click check out.
Thanks for the awesome quick responses.
There is a simple code snippet for doing that: https://easydigitaldownloads.com/docs/redirecting-to-checkout-when-adding-an-item-to-the-cart/
Hey Pippin, great meeting you @pressnomics… starting to take a look at some of your work and just wanted to say great job.
Also quick question about this article… knowing you’re working /w envato is there a way to integrate with them so when a purchase is made through either code canyon or themeforest the new client gets put into EDD?
Thanks
It was my pleasure 🙂
Do you mean create a history of the purchase in EDD?
Hai Pippin ,
Installed both the plugin of EDD and EDD- Software Licenses and i added the some code from the document into my custom plugin but the version update is not showing…
Open a support ticket and I’ll be happy to help you: https://easydigitaldownloads.com/support/forum/add-on-plugins/software-licensing/
Hi
great Work ! i m developer i like your plugin its its very helpful plugin thanks for shareing this i realy thankful to you please check my site: http://themesupdate.net/
Hey Pippin is it possible to group several different products together into a cart and sell one licence to update them all. And different customers can add different products to the cart to get that one update licence. My use case here is clients on a maintenance plan, and adding the premium plugins and normal plugins they use for the site into a licensed maintenance plan. Thereby them renewing on the plan also updates their plugins from my lists. I in-turn have cashflow to renew my dev licences, hosting etc, but the updating maintenance is removed, and the heart ache when they stop a maintenance plan of trying to remove my premium licences is removed. Does that make sense, and is it possibly from this extension?
when i update my plugin it’s failed and in console show 500 internal server error
Thank you very much for making this valuable article very useful and with this article I was able to launch the update section for my WordPress plugin.