• Hello,

    New to wordpress and woocommerce, trying to keep virtual downloads stored locally but out of the media library.
    I have a working setup where downloads are encrypted in a table, and access given through a virtual path made by hooking into the template_redirect action. From there I look at query string info to see what’s being requested, and determine who is logged in, to see if the user has access to the download, and if so decrypt the blob and send it back. This gives me more security and control (I think) over who is allowed access (Contributors upload their files and can access their own files but not each others’ files, admin can access all files to approve them, purchasers can access their orders).

    This all works; it is then a matter of setting the url of the downloadable file of the product to be this URL that template_redirect will catch and handle. Then the url will be given to the customer once they complete the order, and they can download it.

    But woocommerce sees that the URL points to somewhere on the server (rather than external), and seeing that the file location doesn’t actually exist on the server, it doesn’t like it (I am using the WC_Product_Simple class to create the products programmatically).

    My question then: I doing this all wrong? fighting against the design of woocommerce? Should I instead just keep the files on the server in the media library and go about all this a different way, or could I get woocommerce to accept this virtual path as the URL to the downloadable file?

    Thank you for your time.

  • The topic ‘Storing Virtual Downloads using Encrypted Table and Template_redirect’ is closed to new replies.