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:
- Install and activate the free Loco Translate plugin
- Navigate to Loco Translate → Plugins in your WordPress admin
- Find "PDF Invoices & Packing Slips for WooCommerce" in the list
- Select the language you want to modify (usually your site's primary language)
- Search for the text string you want to change (e.g., "Shipping", "Total", "Quantity")
- 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:
- Add the code to your child theme's functions.php file, or
- Use a code snippets plugin like "Code Snippets" to safely add custom PHP
- 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.
Related Support Threads Support
-
How i can change Shipping and Total Texthttps://wordpress.org/support/topic/how-i-can-change-shipping-and-total-text/
-
Font size for extra product optionshttps://wordpress.org/support/topic/font-size-for-extra-product-options/
-
Change Size Column List Producthttps://wordpress.org/support/topic/change-size-column-list-product/
-
resize fieldshttps://wordpress.org/support/topic/resize-fields-2/
-
Adjust position of customer name on packing sliphttps://wordpress.org/support/topic/adjust-position-of-customer-name-on-packing-slip/
-
Mark amounts if bigger than 1https://wordpress.org/support/topic/mark-amounts-if-bigger-than-1/
-
Product attributs on several lineshttps://wordpress.org/support/topic/product-attributs-on-several-lines/
-
Editing the filenamehttps://wordpress.org/support/topic/editing-the-filename/
-
“Quantity” to “Qty”https://wordpress.org/support/topic/quantity-to-qty/
-
Change the Size of the Font of the Totalhttps://wordpress.org/support/topic/change-the-size-of-the-font-of-the-total/