Downloadable product and custom uploads directory (1 post)

  1. chknwng
    Posted 2 years ago #

    Hi, I have a problem with downloadable products.

    When you try to download a purchased file, it redirects you to the file path under woocommerce_uploads and the .htaccess does its job and forbids the access.

    My uploads directory is outside wordpress, in http://mysite.local/app/uploads/ and wordpress core is in http://mysite.local/wp/

    I think there is something to do in WC_Download_Handler class (woocommerce\includes\class-wc-download-handler.php), at line 170.

    To fix this until then, I just put this code into a php file :

    add_filter('woocommerce_product_file_download_path', function($file_path, $this, $download_id) {
      return str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $file_path );
    }, 99, 3);

    You can also see:

    I hope this will help some people.


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic