Back to Community

How to Hide or Customize SKU and Product Meta Data in WooCommerce PDF Documents

Content

Many WooCommerce store owners use the 'PDF Invoices & Packing Slips for WooCommerce' plugin to generate professional order documents. A common request is to customize how product metadata, like SKUs and weights, are displayed—or to remove them entirely. This guide explains why this data appears and provides the most effective solutions to control it.

Why Do SKU and Product Meta Appear on PDF Documents?

The plugin pulls product information directly from your WooCommerce store data. By default, it displays the product name and any associated metadata (like SKU, weight, or attributes) that WooCommerce provides. This is standard behavior, but it may not always fit your desired document layout.

Common Solutions to Hide or Customize SKU and Meta Data

Based on community support threads, the most reliable method to modify this information is by adding custom CSS to your PDF documents. This is done using the wpo_wcpdf_custom_styles action hook in your theme's functions.php file or a code snippets plugin.

1. Hiding SKU and Weight

To completely hide the SKU and weight lines from your invoices and packing slips, use the following code snippet:

add_action( 'wpo_wcpdf_custom_styles', function( $document_type, $document ) {
?>
.sku,
.weight {
 display: none;
}
<?php
}, 10, 2 );

2. Hiding All Item Meta Data

If you want to remove the entire section containing SKU, weight, and any other attributes, you can hide the whole meta container:

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

3. Renaming the 'SKU' Label

If your business uses a different term, like 'ISBN' for books, you can rename the label using a translation filter. This code changes any instance of 'SKU' to 'ISBN':

add_filter( 'wpo_wcpdf_html_filters', function( $filters ) {
 $filters[] = array( 'gettext', 'wpo_wcpdf_customize_string_translation', 999, 3 );
 return $filters;
}, 10, 1 );

function wpo_wcpdf_customize_string_translation( $translation, $text, $domain ) {
 if ( $domain == 'woocommerce-pdf-invoices-packing-slips' ) {
  switch ( $text ) {
   case 'SKU':
    $translation = 'ISBN';
    break;
   case 'SKU:':
    $translation = 'ISBN:';
    break;
  }
 }
 return $translation;
}

4. Shortening a Long SKU

For very long SKU numbers, you can limit the number of displayed characters. This snippet shortens the SKU to 10 characters, but you can adjust the $char_limit value:

add_filter( 'wpo_wcpdf_html_filters', function( $filters ) {
 $filters[] = array( 'wpo_wcpdf_order_item_data', 'wpo_wcpdf_trim_long_sku', 999, 3 );
 return $filters;
} );

function wpo_wcpdf_trim_long_sku( $data, $order, $document_type ) {
 $char_limit = 10;
 $data['sku'] = substr( $data['sku'], 0, $char_limit );
 return $data;
}

Important Notes and Troubleshooting

  • Where to Place the Code: Add these code snippets to your child theme's functions.php file or use a reputable code snippets plugin. Never edit the parent theme directly.
  • Clear Cache: After adding the code, clear any site or browser cache to see the changes reflected in your next PDF generation.
  • Document Types: These solutions typically work for both Invoices and Packing Slips. Note that Receipts are part of a Professional extension, and their styling may be handled differently.
  • New Orders Only: Some filters, particularly those affecting product names, may only apply to new orders placed after the code is added, as WooCommerce stores the product name in the order data at the time of purchase.

By using these code snippets, you can gain precise control over the appearance of product metadata in your WooCommerce PDF documents, ensuring they match your business's branding and needs.

Related Support Threads Support