Back to Community

How to Customize Your WooCommerce Packing Slips: Common Issues and Solutions

Content

Many WooCommerce store owners use the 'PDF Invoices & Packing Slips for WooCommerce' plugin to manage their order documents. A common area of customization is the packing slip, which often needs to be tailored for warehouse use, shipping providers, or specific business requirements. This guide covers the most frequent packing slip customization requests and how to address them using the free version of the plugin where possible.

Common Packing Slip Customizations

Based on community discussions, here are the most sought-after changes and how to achieve them.

1. Changing the Paper Size (e.g., for 4x6 labels)

The default plugin template is designed for standard paper sizes like A4. However, you can set a custom paper size for packing slips using a code snippet. This is useful for printing on smaller labels.

/**
 * Set a custom paper size for packing slips (4x6 inches)
 */
add_filter( 'wpo_wcpdf_paper_format', function( $paper_format, $document_type ) {
 if ( $document_type == 'packing-slip' ) {
  $width = 4; //inches
  $height = 6; //inches
  $paper_format = array( 0, 0, $width * 72, $height * 72 );
 }
 return $paper_format;
}, 10, 2 );

You may need to add additional CSS to adjust the layout for the smaller format.

2. Removing the Shop Logo and Address

To remove the shop logo and address from only the packing slips, you can use custom CSS via a code snippet.

/**
 * Hide shop logo and address on packing slips
 */
add_action( 'wpo_wcpdf_custom_styles', function( $document_type, $document ) {
 ?>
 .packing-slip table.head {
  display:none;
 }
 <?php
}, 10, 2 );

3. Adding Custom Data (e.g., Customer Phone, Role, or ACF Fields)

You can display additional order, customer, or product data on your packing slips using hooks.

To add the customer's phone number: This is typically available if you have the Professional extension. However, if you are using a custom template, you can try to access the data with $this->shipping_phone.

To add the customer's role:

/**
 * Display customer role on packing slip
 */
add_action( 'wpo_wcpdf_after_order_data', function($document_type, $order) {
 if ( $document_type == 'packing-slip' ) {
  if( $user = $order->get_user() ) {
   global $wp_roles;
   $customer_role = translate_user_role( $wp_roles->roles[$user->roles[0]]['name'] );
   ?>
   <tr class="customer-role">
    <th>Customer Role:</th>
    <td><?php echo $customer_role; ?></td>
   </tr>
   <?php
  }
 }
}, 10, 2 );

To add an ACF custom field from products: The process involves fetching the product meta. You can find guides on the plugin's documentation for displaying custom fields.

4. Adjusting Font Size and Layout Spacing

If the text on your packing slip is too small or the spacing is off, you can adjust it with custom CSS.

/**
 * Adjust packing slip font size and spacing
 */
add_action( 'wpo_wcpdf_custom_styles', function( $document_type, $document ) {
 ?>
 .packing-slip {
  font-size: 10pt; /* Adjust font size */
 }
 .packing-slip .document-type-label {
  margin: 2mm 0;   /* Adjust title margins */
 }
 .packing-slip table.order-data-addresses {
  margin-bottom: 5mm; /* Adjust space after addresses */
 }
 <?php
}, 10 , 2 );

Important Notes and Limitations

  • Code Snippets: The solutions above require adding code to your site. You can add this code to your child theme's functions.php file or use a code snippets plugin. Always test code on a staging site first.
  • Free vs. Premium Features: The 'PDF Invoices & Packing Slips for WooCommerce' team offers premium extensions that provide a user interface for many of these customizations without code. Features like adding product images, sorting items, hiding virtual products, automatically emailing slips, and adding numbering to packing slips are part of these paid extensions. Due to WordPress.org forum guidelines, support for those paid features cannot be provided here.
  • Data Source: Remember that the information on the PDF (like the shipping address) is pulled directly from the order data. If the information is wrong on the PDF, it is likely wrong in the WooCommerce order itself. Check for conflicts with other plugins that might be modifying order data.

By using these code snippets, you can significantly customize your packing slips to better fit your workflow. For more complex needs involving the premium extensions, you would need to contact the plugin's team directly.

Related Support Threads Support