Back to Community

How to Remove or Customize Data on Your WooCommerce PDF Invoices and Packing Slips

Content

Customizing the appearance of your PDF invoices and packing slips is a common need for WooCommerce store owners. Whether you want to remove specific information like SKUs, weights, or shipping methods, or simply change the layout to better fit your workflow, the 'PDF Invoices & Packing Slips for WooCommerce' plugin offers several ways to achieve this. This guide covers the most effective methods for removing and customizing data on your PDF documents.

Why Customize Your PDF Documents?

There are many reasons you might want to tweak the default PDF output. You may need to hide information that's irrelevant for internal packing, remove sensitive data, comply with regional invoice requirements, or simply make the document layout cleaner and more professional. Common requests include removing the shop name, subtotals, SKUs, weights, shipping method details, or specific order metadata.

Method 1: Using Custom CSS (Quickest Solution)

For simple visual changes like hiding elements, adding borders, or changing text formatting, custom CSS is often the fastest approach. The plugin provides a hook specifically for this purpose.

Example: Hiding the Shop Name and Product Metadata

add_action( 'wpo_wcpdf_custom_styles', function( $document_type, $document ) {
 ?>
  .shop-name, .item-meta {
   display: none;
  }
 <?php
}, 10, 2 );

Example: Adding Lines Between Order Items

add_action( 'wpo_wcpdf_custom_styles', function( $document_type, $document ) {
 ?>
  .order-details tr {
   border-bottom: 1px lightgray solid;
  }
 <?php
}, 10, 2 );

How to Use This Code: Add this code to your child theme's functions.php file or a code snippets plugin. The .shop-name and .item-meta are CSS classes used in the PDF template. You can find other selectors by inspecting the HTML structure of your PDF document.

Method 2: Using Filter Hooks for Functional Changes

When you need to modify data or functionality rather than just hide elements, filter hooks are more appropriate. These PHP snippets can change document titles, modify addresses, or remove bulk actions.

Example: Changing the Packing Slip Title

add_filter( 'wpo_wcpdf_packing_slip_title', function( $title, $document ) {
    $title = 'Packing Slip/Delivery Order';
    return $title;
}, 10, 2 );

Example: Removing Bulk PDF Actions from the Orders List

add_filter( 'wpo_wcpdf_bulk_actions', '__return_empty_array' );

Method 3: Creating a Custom Template (Most Flexible)

For complete control over the layout and content, creating a custom PDF template is the best long-term solution. This involves copying the plugin's template files to your child theme and modifying them directly. This method prevents your customizations from being lost during plugin updates.

Steps to Create a Custom Template:

  1. In your WordPress admin, go to WooCommerce > PDF Invoices > Status and check the path for template files.
  2. Copy the template files you want to modify (e.g., invoice.php or packing-slip.php) from the plugin's directory to a new folder in your child theme: your-child-theme/woocommerce/pdf-invoices.
  3. Edit the copied files in your child theme to remove or rearrange elements as needed.

Important Note: When editing template files, it's crucial to understand the PHP code structure. For example, if you want to remove only the subtotal from the totals section, you would need to identify and conditionally exclude the specific loop that generates that line, rather than deleting code that controls all totals.

Method 4: Plugin Settings

Before resorting to code, always check the plugin's settings. Some display options can be controlled directly from the dashboard. For instance, to prevent customers from downloading invoices from their 'My Account' page, you can navigate to WooCommerce > PDF Invoices > Documents > Invoice and set "Allow My Account invoice download" to "Never".

Troubleshooting Common Issues

  • Changes don't appear: Clear any caching plugins and regenerate the PDF to see your changes.
  • Broken layout after editing templates: Double-check your PHP syntax. A missing bracket or semicolon can break the entire document.
  • Unexpected elements appearing: Some data, like shipping method details or custom metadata, might be added by other plugins. You may need to identify the specific CSS class or hook related to that data.
  • Need to hide specific order meta: If custom CSS hides too much (like all metadata when you only want to hide some), you may need a more targeted approach using template edits or advanced filters.

Conclusion

Customizing your WooCommerce PDF documents doesn't have to be complicated. For quick visual tweaks, start with custom CSS. For functional changes like modifying titles, use filter hooks. For complete layout control, create a custom template in your child theme. Always test changes in a staging environment first, and remember that using a child theme protects your customizations from being overwritten during updates.

Related Support Threads Support