Overwrite / add to function download pdf product (3 posts)

  1. jvels
    Posted 2 years ago #


    I have created a hack, so it is possible to sell PDF files which get stamped with coustomer information and get a password (customer email).

    I have done the hack direct in the core file woocommerce-functions.php (the function woocommerce_download_product() )

    I would like to hear if it is possible to do the changes / overwrite the function in a more elegant way, because next time woocommerce get updated the changes would be lost.

    My plan are to create it as a free plugin / extention / modification.

    Anybody there can help?

    Best Regards
    Jesper Vels


  2. bondies
    Posted 2 years ago #

    Hi Jesper,

    I am trying to extend the download_product functionality also.

    Looking through the documentation I think the best way to do this is by building a plugin & creating a function that uses the hook woocommerce_download_product (as listed in woocommerce-functions.php)

    The trigger for this is

    // Trigger action
    		do_action( 'woocommerce_download_product', $email, $order_key, $product_id, $user_id, $download_id, $order_id );

    I just need to work out how to get this to work with my plugin I am currently using
    add_action('woocommerce_download_product', array('woocommerce_myluginclass', 'mypluginfunction')); but it doesn't seem to do anything.

    I suspect this will be depending on the options set for the File Download Method

    If you make any progress please let me know.

  3. bondies
    Posted 2 years ago #

    I have been doing some further digging in the source.


    Should only activate once the payment has been accepted as correct, could this be a better option?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic