• Resolved Rittick Mondal

    (@devrittick)


    add_action( 'wpo_wcpdf_before_item_meta', 'custom_pdf_styles', 10, 2 );
    function custom_pdf_styles( $document_type, $document ) {
    ?>
    <style>
    .weight { display: none !important; }
    </style>
    <?php
    }

    Solution

    Place this code in your theme’s functions.php file and weight will be hidden.

    In the same way, you can hide other information from the invoice PDF or packing slips. To find the class within the plugin, go to templates -> Simple -> and then select the desired template (invoice.php or packing-slip.php). Locate the add_action hook (for me, it’s wpo_wcpdf_before_item_meta). Modify the hook according to your requirements, and use it to add extra content or apply custom CSS.

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

    (@yordansoares)

    Hi @devrittick,

    Please note that we have a dedicated hook to set your own CSS rules: wpo_wcpdf_custom_styles
    See: Using custom styles

    For instance, to hide the weight in the packing slip, you can use the following code snippet:

    /**
    * PDF Invoices & Packing Slips for WooCommerce
    * Apply custom styles to the PDF documents
    */
    add_action( 'wpo_wcpdf_custom_styles', function( $document_type, $document ) {
    ?>
    /* Hide the weight in packing slips */
    .packing-slip .item-meta .weight { display:none }
    <?php
    }, 10, 2 );

    You can limit the scope of the rule per-document basis, as I did in the code above, using the document selector: .invoice, .packing-slip, etc.

    Thread Starter Rittick Mondal

    (@devrittick)

    I tried using wpo_wcpdf_custom_styles, but it’s not working for me.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @devrittick,

    I tried myself the code snippet I shared above, and it is working with the packing slip, as expected.

    Could you please double-check that the code is activated correctly? If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide:?How to use code snippets

    In the case that you want to remove the weight in both the invoice and packing slip, please use this code instead:

    /**
    * PDF Invoices & Packing Slips for WooCommerce
    * Apply custom styles to the PDF documents
    */
    add_action( 'wpo_wcpdf_custom_styles', function( $document_type, $document ) {
    ?>
    /* Hide the weight in all PDF documents */
    .item-meta .weight { display:none }
    <?php
    }, 10, 2 );
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.