• Resolved Jason

    (@jjoannides)


    Hi Jonas,

    I have a client that would like to have the names of the two PDFs that are send out changed. Is it possible to set what each document is called.

    Thanks

    Jason

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author flinnn

    (@flinnn)

    Hi Jason,

    yes, this is possible, please follow this guide: https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/custom-pdf-filenames/

    Best,
    Jonas

    PS: If you like Donation Platform for WooCommerce and want to support the further growth and development of the donation plugin, please consider a 5-star rating on wordpress.org.

    Thread Starter Jason

    (@jjoannides)

    Ok, I will have a read.

    Thanks again Jonas

    P.S. Done the review for you

    Thread Starter Jason

    (@jjoannides)

    Hi Jonas,

    I have tried this code but is not working. Am I missing something

    add_filter(‘wpo_wcpdf_filename’, ‘wpo_wcpdf_custom_filename’, 10, 4);
    function wpo_wcpdf_custom_filename($filename, $template_type, $order_ids, $context) {
    $count = count($order_ids);
    $name = “”;
    if ($template_type == ‘thank-you-certificate’) {
    $name = “Project_Certificate”;
    } elseif ($template_type == ‘donations_receipt’) {
    $name = “Project_Receipt”;
    } else {
    $name = $template_type;
    }

    if ($count == 1) {
        $document = wcpdf_get_document($template_type, $order_ids);
        if ($number = $document->get_number()) {
            $suffix = $number;
        } elseif (isset($document->order)) {
            $number = $document->order->get_order_number();
        } else {
            $number = $order_ids[0];
        }
        $suffix = $number;
    } else {
        $suffix = date('Y-m-d'); // Format: 2020-11-11
    }
    
    $filename = $name . '-' . $suffix . '.pdf';
    return $filename;

    }

    Thanks

    jason

    Plugin Author flinnn

    (@flinnn)

    Can you increase the priority of the filter?

    add_filter(‘wpo_wcpdf_filename’, ‘wpo_wcpdf_custom_filename’, 100, 4);

    Thread Starter Jason

    (@jjoannides)

    Hi,

    I changed the priority but still not working.

    I did change the one type ‘donations_receipt’ to ‘invoice’ and that did change the receipt, but nothing on the thank you cert

    Plugin Author flinnn

    (@flinnn)

    I’ve checked the code again and it seems like the filter does not apply to the thank you certificate filename. I’ve fixed the issue and it will be released in the upcoming version of the plugin. https://wcdp.jonh.eu/documentation/support/installing-the-latest-development-version-of-donation-platform-for-woocommerce-wordpress-plugin-from-github/

    Best,
    Jonas

    Thread Starter Jason

    (@jjoannides)

    Hi Jonas,

    Thank you, I installed the dev version 1.3.2, but still not taking the code (sort of)

    this is my code so far.

    add_filter('wpo_wcpdf_filename', 'wpo_wcpdf_custom_filename', 100, 4);
    
    function wpo_wcpdf_custom_filename($filename, $template_type, $order_ids, $context) {
    
    $count = count($order_ids);
    
        $name = "";
    
        if ($template_type == 'thank-you-certificate') {
    
            $name = "Project_Cert";
    
        } elseif ($template_type == 'invoice') {
    
            $name = "Project_Receipt";
    
        } else {
    
            $name = $template_type;
    
        }
    
        if ($count == 1) {
    
            $document = wcpdf_get_document($template_type, $order_ids);
    
            if ($number = $document->get_number()) {
    
                $suffix = $number;
    
            } elseif (isset($document->order)) {
    
                $number = $document->order->get_order_number();
    
            } else {
    
                $number = $order_ids[0];
    
            }
    
            $suffix = $number;
    
        } else {
    
            $suffix = date('Y-m-d'); // Format: 2020-11-11
    
        }
    
        $filename = $name . '-' . $order_ids[0] . '.pdf';
    
        return $filename;
    
    }

    the name of the Receipt is perfect, I get Project_Receipt_16209.pdf (note the capitals). The thank you cert, from this code is still funny, the filename is project_cert_16209-pdf.pdf. it is not pulling the $name correctly and is changing the name to lowercase.

    Let me know if I can do anything else

    Jason

    Thread Starter Jason

    (@jjoannides)

    Hi Jonas,

    Don’t know if this is something on your side. When I installed your Dev version, I was looking into something else and on a page where there is a tablepress shortcode it show a 500 error and crash. when i revert to the 1.3.1 release version the error goes away.

    Jason

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.