• Resolved champdor

    (@champdor)


    Hi,

    Can you help me remove product images from PDF invoice?

    I have a custom template. I tried
    – deleting it from invoice.php but I think $item[‘name’] contains the image,
    – adding display:none to “.order-details .item-name img” – no effect.

    Any suggestions?

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

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

    (@yordansoares)

    Hi @champdor,

    Why are you using a custom template? I ask you this because if you are adding some custom details, there are easier ways to achieve the same, e.g. using the PDF template action hooks (I can offer help with that!)

    This way, you could try switching your selected PDF template to our default “Simple” template, which in addition is always up-to-date, and inject your custom details through its action hooks.

    Thread Starter champdor

    (@champdor)

    Out of ignorance ?? I’m all the way in, to use Simple.

    We only use the plugin to print a packing slip but we print the invoice to view the price as well. We are not showing it to customers.

    I only added one line of CSS for the thead not to be black for saving toner. Also we don’t need the product image for toner saving purposes.

    However thorough it is, I still cannot find any way to disable the product image in the documentation. Also how do I add CSS to the Simple template?

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Thanks for providing more details, @champdor:

    Actually, the Simple template should not to display the product image. I wonder if it is a third-party software which is doing that. Did you try switching to the Simple template, under WooCommerce > PDF Invoices > Choose a template, to see if the thumbnails are gone?

    On the other hand, to apply custom CSS rules, you can use the wpo_wcpdf_custom_styles action hook, like this:

    /**
     * PDF Invoices & Packing Slip for WooCommerce:
     * Add custom styles to the PDF documents
     */
    add_action( 'wpo_wcpdf_custom_styles', function ( $document_type, $document ) {
    	?>
    	/* Put your custom CSS rules below */
    	<?php
    }, 10, 2 );

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

    Thread Starter champdor

    (@champdor)

    Image: I don’t get it. Our snippet should only work on Checkout:

    // CHECKOUT: product image in order summary
    add_filter( 'woocommerce_cart_item_name', 'pkt_product_image_on_checkout', 10, 3 );
    function pkt_product_image_on_checkout( $name, $cart_item, $cart_item_key ) {
    ? ? if ( ! is_checkout() ) {
    ? ? ? ? return $name;
    ? ? }
    ? ? $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
    ? ? $thumbnail = $_product->get_image();
    ? ? $image = '<div class="chk-product-image">' . $thumbnail . '</div>';
    ? ? return $image . $name;
    }

    Thank you for the action. CSS works now in Simple template.

    Best regards,
    Champdor

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi,?@champdor:

    That code snippet is not being applied to the PDF invoice. Is it possible that you have a second code snippet activate somewhere in your site?

    Thread Starter champdor

    (@champdor)

    Hi,

    Yes, there was another similar code for My account Orders. Once I restricted it for my account endpoints the images went away.

    Thank you for taking the time.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Thanks to you for the update: I’m very happy to hear that you finally got it working the way you wanted it to ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘REmoving product image from invoice’ is closed to new replies.