WordPress filter hook

woocommerce_file_download_path

Defined by WooCommerce and fired by 7 plugins in total, running on 7.4M+ sites between them.

“Filter for the path of the downloadable file.”

How to use woocommerce_file_download_path

It's a filter: your callback receives the value and 2 more arguments, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'woocommerce_file_download_path', function( $file, $product, $key ) {
	// Change $file here.
	return $file;
}, 10, 3 );

Argument names come from WooCommerce Legacy REST API's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

7 plugins that fire woocommerce_file_download_path

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. WooCommerce icon WooCommerce7+ million installs apply_filters( 'woocommerce_file_download_path', $meta_value['file'], $product, $key ) includes/data-stores/class-wc-product-data-store-cpt.php:696
  2. WooCommerce Legacy REST API icon WooCommerce Legacy REST API400,000+ installs apply_filters( 'woocommerce_file_download_path', $file['file'], $product, $key ) includes/legacy/api/v2/class-wc-api-products.php:1537
  3. Dokan: AI Powered WooCommerce Multivendor Marketplace Solution icon Dokan: AI Powered WooCommerce Multivendor Marketplace Solution30,000+ installs apply_filters( 'woocommerce_file_download_path', $file['file'], $product, $key ) includes/Product/Manager.php:579
  4. Add Product Frontend for WooCommerce icon Add Product Frontend for WooCommerce70+ installs apply_filters( 'woocommerce_file_download_path', $file['file'], $product, $key ) public/inc/bytes-save-product.php:41
  5. StoreSuite icon StoreSuite20+ installs apply_filters( 'woocommerce_file_download_path', $file['file'], $product, $key ) includes/Product/ProductManager.php:724
  6. Auto Product After Upload Image icon Auto Product After Upload Image10+ installs apply_filters( 'woocommerce_file_download_path', $file['file'], $product, $key ) auto-product-after-upload-image.php:268
  7. Superstore icon SuperstoreFewer than 10 installs apply_filters( 'woocommerce_file_download_path', $file['file'], $product, $key ) includes/RESTAPI/Product.php:1289

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.