• Resolved slavatarkovskij

    (@slavatarkovskij)


    Hello,

    Can I save a PDF download link to my account?

    That would allow you to review the saved results of a certain set of basket of goods.

    Or how it can be implemented using your plugin.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author David Jensen

    (@dkjensen)

    Hello

    The plugin uses the mPDF library. You can use the action hook

    
    function your_action_name( $mpdf ) {
       // $mpdf is an instance of mPDF object
    }
    add_action( 'wc_cart_pdf_output', 'your_action_name' );
    

    And then output the PDF to a locally stored location, and then perform other actions such as saving the location to the usermeta table.

    You can certainly do what you are looking to do with this plugin but it will take custom programming

    • This reply was modified 4 years, 1 month ago by David Jensen.
    Thread Starter slavatarkovskij

    (@slavatarkovskij)

    Hello,

    Thanks for the quick response.

    But I don’t have a lot of programming experience.

    Kind Regards

    Plugin Author David Jensen

    (@dkjensen)

    Here is a more complete example which will download it to your uploads folder/wc-cart-pdf

    
    function your_action_name( $mpdf ) {
        $upload_dir = wp_upload_dir();
        $upload_pdf_dir = 'wc-cart-pdf';
    
        $upload_dir = trailingslashit( $upload_dir['basedir'] ) . $upload_pdf_dir;
    
        if ( ! is_dir( $upload_dir ) ) {
           mkdir( $upload_dir, 0700 );
        }
    
        $mpdf->Output( trailingslashit( $upload_dir ) . 'WC_Cart-' . date( 'Ymd' ) . bin2hex( openssl_random_pseudo_bytes( 5 ) ) . '.pdf', 'F' );
    }
    add_action( 'wc_cart_pdf_output', 'your_action_name' );
    

    Do note this will save the PDF as a unique filename, but it will not be the same filename as what the user is downloading to their local machine

    Thread Starter slavatarkovskij

    (@slavatarkovskij)

    Hello,

    Thanks.

    But I can’t figure it out. I will look for a ready-made solution.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to save download url in my account’ is closed to new replies.