Selling Custom Files with WooCommerce

Most any eCommerce platform can make it simple to sell a downloadable file to your customers, but what if that file is part of a service? For example, what if your customers purchase a custom logo design or voiceover work for a video?

You won’t be able to provide the file link at the time of purchase, and will instead provide it at a later time after the order is placed. Once the file is removed from the product and is instead tied to the order, it becomes very difficult to add and manage files to share with your customers.

We tried to tackle this concept a bit in a previous post on sending download links to customers after purchase, but this requires the use of a customer-facing order note, which isn’t available in most eCommerce plugins, and requires you to just drop a plan link to an email.

You can still use a customer order note to inform the customer that the newest proof or file is ready, but you can have a bit more finesse over managing the files you share with the customer. Let’s take a look at a slightly more advanced way sell custom files your customers.

Sell Custom Files with WooCommerce: Overview

We’re going to focus on WooCommerce in this tutorial because it’s very simple to add custom fields to an order, display them to the customer, and notify the customer of changes. We’ll also need another free plugin to help us manage our customers’ files: Download Monitor.

If you don’t use Download Monitor, the only real file management for customers exists as part of a product. If you want to add downloadable files to an order, you’d have to create a unique (private) product for every custom job you do, then add that to the “Download Permissions” for the order. This gets to be hard to manage very quickly.

Download Monitor is going to add a layer of file management that will help us restrict downloads, manage file versions, and create download links without requiring the addition of a new WooCommerce product for every customer. It doesn’t tie into WooCommerce by default, but we can use an order custom field to do this for us.

Sell Custom Files with WooCommerce: Create Your Product

Step 1: create your WooCommerce product(s) for your custom digital service. We’ll make this a virtual product that will let us collect payment from our customer and create an order, but we won’t need to tie any downloadable files to this product. We’ll be adding them to Download Monitor instead later.

WooCommerce custom design product

Sell Custom Files with WooCommerce: Create Your Download

Step 2: Configure Download Monitor and create a new Download for every custom job. This has the benefit of making downloads simple to manage in your site while separating them from your products.

First, I’m going to adjust my download template to the “Version list” — I want to show this in the “View Order” part of the account section. You can adjust other settings as desired here.

Download Monitor settings
Change Download Template

Second, I’ll create a download for this order. For every revision I make, I can add a new file as an updated version. A version can also contain multiple files, which is handy if you’ll have several components of a version to share, like both horizontal and vertical versions of the logo.

Versions are very helpful if you’ll need some back and forth with your customer, as they can access different versions as part of the same download.

The great thing about Download Monitor is that you can also restrict downloads to logged in users. This means that the regular download link will not work for a guest user, and will only work for a logged in customer on your site.

Download monitor create a download
Create Download for the Order

If a non-logged-in user tries to use a download link that’s been shared with them, they’ll be redirected to the “No access” page (you can adjust the message in the settings).

Download Monitor no access

All addition of your files and updates will take place on the download. This way, you can manage files and revisions in a dedicated place, and they’ll always keep the same download ID, so you won’t need to constantly update your order.

Take note of your download ID, and head over to your customer’s order.

Sell Custom Files with WooCommerce: Add Download ID to the Order

Here’s why I like using Download Monitor for selling custom files: all I have to do tie my download to the order is add one custom field. This lets me share the latest version or all versions, I can share multiple files as part of a single version easily, and I can limit downloads to logged in users.

In the order “Custom Fields” box, add a new custom field titled custom_file (you’ll have to click “Enter New” the first time you do this). For the order, enter the ID of your download.

Sell Custom Files with WooCommerce: Add Download Monitor ID
Add Download ID to order

This will tie the order to your download, and now we’ll add a couple small code snippets to make these accessible to your customers.

Sell Custom Files with WooCommerce: Add a “Recent Orders” Action Button

First, let’s add an order action for customers. When a customer sees the “Recent Orders” list in the account section, let’s add an action button (only if the order is paid for) to download the most recent version of the file(s). You can add this where you keep your custom code.

/**
 * Adds a custom order action in the "Recent Orders" table of the WooCommerce account
 *   if a download ID is entered as a "custom_file" order custom field
 * Button downloads custom files for the order
 * Requires Download Monitor
 *
 * @param array $actions the actions available for the order
 * @param \WC_Order $order the order object for this row
 * @return array the updated order actions
 */
function sww_add_custom_file_order_action( $actions, $order ) {

	// only add our button if the order is paid for\
	if ( ! $order->is_paid() ) {
		return $actions;
	}

	$order_id = is_callable( array( $order, 'get_id' ) ) ? $order->get_id() : $order->id;

	// add our action if the order has the custom_file field set
	if ( $file_id = (int) get_post_meta( $order_id, 'custom_file', true ) ) {

		$actions['files'] = array(
			'url'	=> trailingslashit( get_site_url() ) . trailingslashit( get_option( 'dlm_download_endpoint' ) ) . $file_id,
			'name'	=> __( 'Get Files', 'my-textdomain' ),
		);
	}

	return $actions;
}
add_filter( 'woocommerce_my_account_my_orders_actions', 'sww_add_custom_file_order_action', 10, 2 );

(If you don’t want the first check for paid orders, feel free to remove it!)

This code will add an action button to my orders list only if the order is paid for, and if I’ve added the custom_file field to the order.

Sell Custom Files with WooCommerce: Recent Orders download button
Add “Get Files” action

Now customers can download the most recent version of my file(s) with one click.

Sell Custom Files with WooCommerce: Add a “Custom Files” Section to “View Order”

We may want to show all revisions, so we can also add the files to the “View Order” screen. If a customer clicks the “View” action, let’s show a list of all versions to the customer.

We can do so with a bit of code to add a “Custom Files” section to the account.

/**
 * Adds a section with custom downloadable files to the "View Order Screen"
 *    if the order has a "custom_file" custom field with a download ID
 * Requires Download Monitor
 *
 * @param int $order_id the ID of the order being viewed
 */
function sww_add_custom_file_view_order( $order_id ) {

	$order = wc_get_order( $order_id );

	// only add our section if the order is paid for
	if ( ! $order->is_paid() ) {
		return;
	}

	$order_id = is_callable( array( $order, 'get_id' ) ) ? $order->get_id() : $order->id;

	// add our section to shown download links if the order has the custom_file field set
	if ( $file_id = (int) get_post_meta( $order_id, 'custom_file', true ) ) {

		$content = '<h3>Custom Files</h3>';
		$content .= do_shortcode( '[download id="' . $file_id . '"]' );
		echo $content;
	}
}
add_action( 'woocommerce_view_order', 'sww_add_custom_file_view_order', 9 );

This will add a list of all available versions for the customer to access.

Sell Custom Files with WooCommerce: View Order custom file list

Now you can manage files with a dedicated system, version those files, add multiple files in a version for download, and restrict access to those files. They can be tied to your WooCommerce orders with one field, making it easier for you to manage files and for your customers to access them from the account.

Sell Custom Files with WooCommerce: Taking it Further

The one thing this won’t do is notify customers. This is where the customer-facing order note still comes in handy. However, this can serve purely as a notification now, and no longer as both notification and file management. You can add an order note each time a new revision is made to the associated download, and customers can quickly and easily get all information in their accounts.

If you want fine-grained control over download access, there are also premium extensions available for Download Monitor that can help with this.

For example, the Advanced Access Manager plugin ($39) can let you restrict your downloads to only allow a certain number of downloads, or restrict them to a specific users (not just anyone who’s logged in). This lets you take your file management and restriction further than you can with order notes.

Sell Custom Files with WooCommerce

Selling custom files with WooCommerce (or any eCommerce plugin!) is no easy feat since downloadable files are always attached to products rather than orders. However, using Download Monitor gives you a layer of file management for multiple files and revisions, while WooCommerce order custom fields allow us to tie an order to a download fairly simply.

Download Monitor is free, so you can give it a try yourself to manage custom files for the services you offer on your WooCommerce site.

Need some help using this tutorial or taking it further? We recommend Codeable to help with these projects.
[optin-monster-shortcode id=”nwltspncrcafgjpcetis”]

28 Comments

  1. Awesome! I saw the original post and I’m glad I found this update. This is exactly what I need for our custom services, but it is a little convoluted, as you made reference to in the article. In this age, I’m surprised that nobody has built a plugin or extension for this type of service. But in the meantime, I’ll give this a shot and see how it works on voicemagic.studio. Thanks for the article.

  2. I followed these instructions to the letter and it worked flawlessly. Thank you for the tip, research, and thorough instruction. As my previous comment stated, this is a little bit of a convoluted process, but it only took me about an hour to setup and test thoroughly. Now I just have to create the download page and attach the id to the order. And add a notification note of course. I believe it is most definitely worth the small amount of time it took to do this. The purchase note for delivering files does work, but it’s a little frustrating for the client when trying to manage those files. This article is to my knowledge to the solution to date.

    1. Hey Mark, thank you so much for the feedback here! I agree it’s a bit of a strange process, but really glad to hear it’s working out for you ๐Ÿ™‚

  3. Hey Becka,

    I have one quick question. I have completely scoured the web for more than a week and find it hard to believe nobody else has needed this.

    Since I sell custom products and deliver the files via download monitor ^^ post order, I have the need to put an “approve” and “request revision” button on the order details page. When the customer clicks “approve” it would change the woocommerce status to something like “approved”, so we know it has been approved. If the customer clicks “request revision”, a box should open so they can describe the revision. When they submit the revision, the status would change to “revision requested” and their revision note would show in the Woocommerce order notes section.

    Sounds like a lot but it is very simple. Do you know of any plugins that would do that, or if there is a developer that could write that script for me for a small fee?

    This is a crucial part of my ordering and approval process. I can of course make notes to the customer through the backend, but then they would have to email me with change requests or approval, which is more steps than I would like for my customer.

    If you have any suggestions, I would greatly appreciate it. If I can get this resolved, I’m in business! ๐Ÿ™‚

  4. Thank you so much Beka!

    I searched for weeks trying to figure out how to do this without having to pay $thousands for a custom solution. To echo Mark, I can’t believe this feature hasn’t been added to WooCommerce.

    Everything is working great so far.

  5. Hi there. and if there is a daddy in your life.. happy fathers day!

    I have gotten stuck on this code. I use “my Custom Functions” as a way of keeping all my php code in one place. It automatically checks the code before installing it. When I place either one of these snippits in there it comes back with the following message.

    403 Forbidden

    A potentially unsafe operation has been detected in your request to this site, and has been blocked by Wordfence.

    If you are an administrator and you are certain this is a false positive, you can automatically whitelist this request and repeat the same action.

    I can white list the code but wanted to make sure there would not be a problem.. I copied and pasted it exactly. The plugin automatically puts in the php front and end brackets.

    wp version. 4.5.2
    woocommerce version 2.6.1

    I have spent so much money on plugins already.. can you help me with your code?

    ~Sandy and Steven

    1. Hey Sandy and Steven, I’m not having any issues while adding this to my site. Check if you’re including the `<?php in the top and if it’s needed at all, I’m not sure if your plugin will handle that properly. I use “Code Snippets” for this as it will check for opening PHP tags like this automatically ๐Ÿ™‚

  6. Thank you Beka this is extremely helpful. However, I also second Mark’s last question as this is almost crucial in managing approvals from customers. Any thoughts on plugs ins that I can incorporate to include the control of approvals/revisions of quotes on customer downloadable products? Basically would be integrating workflow tool that updates status of the order.

    Thanks again for your contributions!!

    Brad

  7. Hello,
    Thank you very much, this is a great match of my needs. but I’m sorry to say that I’ve made all your steps but my client couldn’t download the file. I see “get files” button. also, I see the file “asdasdads.docx” in the recent orders, but when click to the file, I see an error message “Oops! That page canโ€™t be found. It looks like nothing was found at this location. Maybe try one of the links below or a search?”

    What could be the problem? how should I fix this? Is there a problem with download path? or my server, or authorisation etc. Where should be the problem?

    Thank you very much for your answer

    1. Hey Zihni, it sound server-specific, like that file isn’t readable. Try unchecking “Members Only” on the file, and if you still can’t download it, you’d likely need to look at the permissions on the folder where that file is stored with the hosting company (I think it’s in the dlm_uploads directory but not 100% sure since I haven’t used it in a bit).

      1. Hi Beka,

        I found where the problem is. My website is multilingual with Polylang plugin. But the “download monitor” plugin creates the link without index.php/en or “tr” or “de” etc. I need the link as

        “wwww.asdasdasd.com/index.php/en/download/560/”

        but download monitor creates the link as

        “www.asdasdasd.com/download/560”

        now do you have any idea how can I fix the link?

        Regards,
        Zihni

  8. Hi,
    first of all thank you for the code, it is working just fine.

    What i want to change now is that the download button (the button or at least the file) is visible under “Downloads” in My-Account.

    Because i think it would be nice if the customer can find his download in the “downloads” section of his account.

    Is this possible and if yes, how?

    Thank you very much.

    Regards

  9. Hi Beka,

    Like many I searched the web for days before I found this post. Absolutely top, got it up and running in minutes and it works fantastic.

    Thank you so much for providing this solution.

    Cheers,
    Charles

  10. Hi. Do you know if I could use this to do the following: I want to use woo to sell software licenses on a site. The licenses will be in the form of text files the buyer downloads after purchase. But I need each of the files to be only sold once as each code is unique. I want to do it with one product on the site that has multiple text files that can be downloaded, one each time someone buys a product and then this gets removed from the available text files. For example, I have a software product that has 50 available license codes. I put the product live with an inventory of 50 and each time someone buys a license the inventory drops and each buyer gets to download one of the 50 text files and once they have bought, it no longer becomes available to buy again.

    1. Hey Ken, this solution would likely be inadequate for that use case, as you’d need to manually give out license keys after purchase since it’s not generating or sending anything after purchase automatically. I’m not sure if the Software Add-on would do this, but I’d start the search there.

    2. Hello Beka, thank you for this article. I am trying to achieve something similar to Ken, but I am selling PDF documents instead. So when a customer makes a purchase, a specific PDF or PDFs are attached to that order, and the purchased documents are removed from the remaining PDF inventory. This article has been a great start, but any other guidance you can provide that would help automate all of this would be great. Thanks and have a great day.

  11. Hi,

    Thank you for this post. I think I can use this for my client.

    There’s one thing I really need: put the download link in the Woocommerde standaard emails, especially the order closed e-mail.

    I am not a coder, so I really do not know how that can be done. Any ideas on this?

    Thanks in advance!

    Regards,
    Bob

    1. Hi,

      I want to notice you that I own WooCommerce v3.2.4.
      And I don’t really see where I put a metakey or custom field in orders…

      Thanks alot for your helping!
      Cheers,
      Nicolas S.

  12. Hi,

    Thanks Beka for this solution.

    In regards to MrBottle’s post from April 17…

    Just wondering if anybody figured out how to add the Download Button to the “My Account/Downloads” list?

    Thanks

  13. Hey Beka. This is one well-written article that not only provides a detailed explanation but also provides the code to implement the solution. This saved me hours of fiddling around and works like a charm.

    I am using your solution for a client that has a website which provides map updates for cars. The map updates are customised based on the VIN number of the car and therefore can only be delivered after the order is placed and is therefore unique to each order.

    Honestly, I could kiss you!

  14. Hi Beka,
    Your article is very good and usefull.
    Do you know if there is an alternative to tie files to orders automatically?
    I need to sell files that are unique (because they have different serial numbers) but content is the same and are produced and ready to be download beforehand.
    I am trying to avoid make the customer wait for my manual intervention and let them download the files as soon as they buy.
    Thanks in advance for your help.

    Best regards.

<em>Hmm, looks like this article is quite old! Its content may be outdated, so comments are now closed.</em>