• Hello,

    We use S3 Uploads to move all of our wp-contents over to AWS S3 and then serve it via Cloudfront: https://github.com/humanmade/S3-Uploads

    Using the premium templates plugin this seemed work fine but a few months back our logo no longer shows on the PDF invoices. If I append &output=html to the PDF URL I can see the external URL just fine but doesn’t appear on the PDF itself.

    Any ideas on how to fix?

    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 @torlock,

    We had an issue with another user in the past who was using a plugin called “WP Offload Media Lite for Amazon S3”. At that moment, the issue was related with the return of the wp_get_attachment_image_src function, which they filter to override its default behavior and pull the URLs from Amazon S3, but we did not receive more feedback from the user, so we do not know whether they found a fix or not, but it seems that you have the same issue they reported.

    That said, with the following code snippet you can set a logo manually as a workaround:

    /**
    * PDF Invoices & Packing Slips for WooCommerce:
    * Set a shop logo manually (this will override the shop logo in the plugin's settings)
    */
    add_filter( 'wpo_wcpdf_header_logo_img_element', function( $img_element, $attachment) {
    // Set the URL of your shop logo below:
    $shop_logo_url = 'https://img.logoipsum.com/288.svg';
    return "<img src='{$shop_logo_url}'/>";
    }, 10, 2 );

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

    Thread Starter Alexander

    (@torlock)

    Hi @yordansoares,

    Thanks for the quick reply.

    Unfortunately not having much luck with that code – still getting this in the logs:

    2024-10-21T18:25:37+00:00 Critical Header logo file not found.

    I updated the image location, removed the currently set logo, cleared all caches to be safe and regenerated an invoice but no logo.

    /**
    * PDF Invoices & Packing Slips for WooCommerce:
    * Set a shop logo manually (this will override the shop logo in the plugin's settings)
    */
    add_filter( 'wpo_wcpdf_header_logo_img_element', function( $img_element, $attachment) {
    // Set the URL of your shop logo below:
    $shop_logo_url = 'https://d5bm31en4blvo.cloudfront.net/uploads/2019/12/logo.png';
    return "<img src='{$shop_logo_url}'/>";
    }, 10, 2 );
    Thread Starter Alexander

    (@torlock)

    I notice there is no img attribute in the &output=html version either with this solution.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @torlock,

    Is it possible to see the HTML output of a testing invoice/packing slip to check the source code?

    You can use https://www.file.io/ to upload the file and share the file URL here (this service deletes the file after downloading, so please don’t test the download link yourself!).

    Thread Starter Alexander

    (@torlock)

    Sure, here’s the link: https://file.io/GivcfUB3DT3K

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @torlock,

    Thanks for sharing that file. I have checked the code and, as you said, the markup for the shop logo image is not there. This is different for the case I mentioned above, so please answer the following questions to try to understand what is happening in your case:

    1. Could you please check if you are using whether the default “Simple” template or a custom template in WooCommerce > PDF Invoices > General > Choose a template?

    2. In this same screen, do you have a shop logo set in the “Shop header/logo” option?

    3. Is the HTML output you sent from a PDF invoice generated before or after setting a shop logo?

    The last question is not trivial: Please note that PDF invoices created previously are not updated when you change the plugin’s settings in a latter stage, therefore, if you change your shop details (like your shop logo), the previous invoices will not be affected, displaying nothing (if there was not a logo set at the moment of its generation) or the logo version you had then.

    In brief, we store both the document and shop settings per-order basis for historical reasons. For instance, if you change your shop address in the future, it should not affect old PDF invoices that you generated when your store was located in the old address.

    That said, if you are just playing with the plugin configuration, or this is a new installation, you could try to activate the “Test mode” temporarily, under WooCommerce > PDF Invoices > General > Test mode. See: Show PDF documents with the latest settings.

    Thread Starter Alexander

    (@torlock)

    Hi @yordansoares

    To answer your questions:

    1. We are using the Simple Premium template
    2. No logo is currently set as I thought this might interfere with the filter code, I will add the logo back, check and report back but let me know which was is preferable
    3. This was generated after the code was published and checking the latest orders since and still nothing
    Thread Starter Alexander

    (@torlock)

    Hello,

    Still no luck with the logo set as well.

    I’ve also checked our custom template and hardcoded the logo in there but this doesn’t work either:

    First few lines of child-theme/woocommerce/pdf/customtemplate/invoice.php

    <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>

    <?php do_action( 'wpo_wcpdf_before_document', $this->get_type(), $this->order ); ?>

    <table class="head container">
    <tr>
    <td class="header">
    <img src='https://d5bm31en4blvo.cloudfront.net/uploads/2019/12/logo.png'/>
    ?>
    </td>
    <td class="shop-info">
    <?php do_action( 'wpo_wcpdf_before_shop_name', $this->get_type(), $this->order ); ?>
    <div class="shop-name"><h3><?php $this->shop_name(); ?></h3></div>
    <?php do_action( 'wpo_wcpdf_after_shop_name', $this->get_type(), $this->order ); ?>
    <?php do_action( 'wpo_wcpdf_before_shop_address', $this->get_type(), $this->order ); ?>
    <div class="shop-address"><?php $this->shop_address(); ?></div>
    <?php do_action( 'wpo_wcpdf_after_shop_address', $this->get_type(), $this->order ); ?>
    </td>
    </tr>
    </table>

    Is it possible the plugin isn’t picking up on the template, otherwise would it just go for the direct image rather than try for the logo set in WP?

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