• Resolved aperezvde

    (@aperezvde)


    I want to change the route where it gets the PDFs that are attached in the mail.

    The original path is

    wp-content/uploads/wpo_wcpdf

    And I want you now to take them from

    wp-content/uploads/pdf_orders

    and the PDFs have the name of

    (idorder)_cotizacion_(nameblog).pdf

    I was looking in the code to change the route but I can’t find it.

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @aperezvde,

    I want to change the route where it gets the PDFs that are attached in the mail. The original path is wp-content/uploads/wpo_wcpdf And I want you now to take them from wp-content/uploads/pdf_orders

    You can customize the temporary folder for the attachments by adding this code snippet to your site:

    /**
     * Change the PDF document temp path to 'wp-content/uploads/pdf_orders/'
     */
    add_filter( 'wpo_wcpdf_tmp_path_attachments', function( $tmp_path ) {
    	$upload_dir = wp_upload_dir();
    	$upload_dir_path = $upload_dir['basedir'];
    	$attachments_tmp_path = $upload_dir_path . '/pdf_orders/';
    	if ( ! is_dir( $attachments_tmp_path ) ) {
    		mkdir( $attachments_tmp_path, 0700 );
    	}
    	return $attachments_tmp_path;
    }, 10, 1 );

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

    However, this code snippet needs a new improvement that will be available in the next release, so I have prepared a beta release for you, so you can enjoy this enhancement before it’s public available. In short, please replace your installed version of the plugin with this one: https://we.tl/t-Kqv5rIRhn1

    and the PDFs have the name of (idorder)_cotizacion_(nameblog).pdf

    You can customize your PDF document filename with the Professional extension:

    A screenshot that display the document title and filename fields available in the Professional extension

    Or using the wpo_wcpdf_filename filter hook. See some examples here: Custom PDF filenames

    Thread Starter aperezvde

    (@aperezvde)

    Hello!
    Thank you very much for the contribution.

    I already installed the beta version

    And add the function in functions.php file
    of my template

    But the file was not generated in the /pdf_orders/ folder

    Keep attaching the file in the email and the file continues to be generated in
    /uploads/wpo_wcpdf

    maybe I’m doing something wrong

    Plugin Contributor Yordan Soares

    (@yordansoares)

    You can check if the code snippet is being applied by seeing the Temporary attachments folder path, under WooCommerce > PDF Invoices > Status > Write Permissions. If the folder there is /uploads/wpo_wcpdf_xxxxx, is because the code snippet is not activated or your plugin was not updated correctly.

    Thread Starter aperezvde

    (@aperezvde)

    I have this plugin installed.
    https://woocommercequoteplugin.com

    Does it have something to do with it?

    • This reply was modified 2 years, 8 months ago by aperezvde.
    Plugin Contributor Yordan Soares

    (@yordansoares)

    I don’t think so. I think the issue could being caused because the code snippet is, actually, not running in your site. Could try adding the code snippet to your site using the Code Snippets plugin?

    Thread Starter aperezvde

    (@aperezvde)

    I still haven’t been able to fix it

    The permissions of the folder are these:
    https://ibb.co/52s8FQM

    I edit the file

    class-wcpdf-main.php
    https://mega.nz/file/OIF0BaAL#tiGAWTOHV04swCR0Rc8qa0V57VQl0tHedYOaFEWZcOs

    PDFs are generated correctly in wp-content/uploads/pdf_orders/
    https://ibb.co/QdJ4JHY`

    But it keeps attaching the file to the route
    /uploads/wpo_wcpdf_xxxxx
    https://ibb.co/C0y1pD9

    In emails.
    https://ibb.co/yNpCRv0

    any other alternative?`

    Plugin Contributor Yordan Soares

    (@yordansoares)

    I edit the file class-wcpdf-main.php

    Unfortunately, we can’t provide support for custom builds. This is not only a bad practice (because in every update you’ll lose your customizations), but it’s also unnecessary: you can take advantage of our PDF action and filter hooks instead, in addition to another action and filter hooks like the one I’m using in the code snippet that I wrote above: wpo_wcpdf_tmp_path_attachments.

    PDFs are generated correctly in wp-content/uploads/pdf_orders/, but it keeps attaching the file to the route /uploads/wpo_wcpdf_xxxxx

    In fact, the second route that you mentioned seems not to be /uploads/wpo_wcpdf_xxxxx but uploads/sites/2/wpo_wcpdf_xxxxx/attachments. Maybe you edited the path here? If so, please use the code snippet I left above instead, in combination with the beta release I shared with you.

    On the other hand, to make sure that you aren’t seeing old files, you can clean your temporary folder under WooCommerce > PDF Invoices > Status > Remove temporary files.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Following up on this topic, I would like to let you know that the improvement in the beta release a shared with you is already available in the latest release we just have launched, so you don’t need that beta version anymore to be able to use the code snippet I wrote for you above, just update your plugin, and that’s it ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘change the route where it gets the PDFs that are attached in the mail.’ is closed to new replies.