Back to Community

How to Customize Text and Labels in Your WooCommerce PDF Documents

Content

Many WooCommerce store owners using the 'PDF Invoices & Packing Slips for WooCommerce' plugin need to customize the text that appears on their documents. Whether you want to change "Shipping" to "Delivery Cost" or "Quantity" to "Qty," these adjustments can make your invoices and packing slips better match your brand's voice.

This guide covers the most common methods for modifying text labels and strings in your PDF documents.

Method 1: Using Translation Files (Recommended for Simple Text Changes)

The most straightforward way to change text labels is by modifying the plugin's translations. Even if you're not translating the plugin to another language, this method allows you to override any text string.

Step-by-Step Instructions:

  1. Install and activate the free Loco Translate plugin
  2. Navigate to Loco Translate → Plugins in your WordPress admin
  3. Find "PDF Invoices & Packing Slips for WooCommerce" in the list
  4. Select the language you want to modify (usually your site's primary language)
  5. Search for the text string you want to change (e.g., "Shipping", "Total", "Quantity")
  6. Enter your custom text in the translation field and save

Important Note: Some text on your PDF documents might actually come from WooCommerce core, not the PDF plugin. If you can't find a specific string in the PDF plugin's translations, check the WooCommerce translations as well.

Method 2: Using Code Snippets (For Advanced Customization)

For more control or when you need to change text that's generated dynamically, code snippets offer a powerful solution. Here's an example that changes the "Quantity" header to "Qty":

/**
 * PDF Invoices & Packing Slips for WooCommerce:
 * Customize the "Quantity" header on the PDF documents
 */
add_filter( 'wpo_wcpdf_simple_template_default_table_headers', function( $headers, $document ) {
    $headers['quantity'] = 'Qty';
    return $headers;
}, 10, 2 );

How to implement this code:

  1. Add the code to your child theme's functions.php file, or
  2. Use a code snippets plugin like "Code Snippets" to safely add custom PHP
  3. Test the changes by generating a new PDF document

Common Customization Examples

Here are some specific examples based on common requests:

Changing Table Headers: The code example above demonstrates how to modify table headers like "Product," "Quantity," and "Price."

Highlighting Specific Values: You can conditionally format text, such as making quantities greater than 1 stand out:

add_filter( 'wpo_wcpdf_order_items_data', function( $data_list, $order, $document_type ) {
    if ( $document_type == 'packing-slip' ) {    
        foreach ( $data_list as $item_id => $item ) {
            if ( $item = $item['item'] ) {
                if ( $item->get_quantity() > 1 ) {
                    $data_list[$item_id]['quantity'] = sprintf( '<span style="color:red"><strong>%s</strong></span>',  $item->get_quantity() );
                }
            }
        }
    }
    return $data_list;
}, 10, 3 );

Troubleshooting Tips

  • Changes not appearing? Clear any caching plugins and regenerate the PDF document
  • Text still not changing? The string might originate from WooCommerce core - check those translation files too
  • Code snippets not working? Ensure you're adding them correctly to your functions.php or via a reliable code snippets plugin
  • Always test changes on a staging site before applying them to your live store

By using these methods, you can customize nearly any text element in your PDF invoices and packing slips to better suit your business needs.