Back to Community

Fixing Common Fatal Errors in PDF Invoices & Packing Slips for WooCommerce

Content

If you're encountering fatal errors when trying to generate PDF invoices or packing slips with the 'PDF Invoices & Packing Slips for WooCommerce' plugin, you're not alone. These errors often appear after plugin updates, theme changes, or conflicts with other plugins. This guide will help you identify and resolve the most common fatal errors.

Understanding the Most Common Fatal Errors

Based on community reports, here are the most frequent fatal errors and their likely causes:

1. "Call to a member function get_header_logo_id() on null"

This error typically occurs in custom PDF templates after a plugin update. The template is trying to access a method that no longer exists or is being called incorrectly.

2. "Call to a member function custom_field() on null"

This error often indicates a conflict with custom code or another plugin that's trying to modify PDF generation.

3. DOMDocument and Dompdf Library Errors

Errors related to DOMDocument or Dompdf usually indicate library conflicts with other plugins or themes.

4. Deprecated Method Warnings

While not fatal errors, deprecated method warnings indicate that custom code needs updating to work with newer plugin versions.

Troubleshooting Steps

Step 1: Identify the Exact Error

Check WooCommerce > Status > Logs for the complete error message and stack trace. The specific file path mentioned in the error will help identify whether the issue is with a template, plugin conflict, or core plugin file.

Step 2: Test with Default Templates

Switch to one of the default templates (Simple or Business) in the plugin settings. If the error disappears, the issue is with your custom template.

Step 3: Check for Plugin Conflicts

Temporarily deactivate other plugins one by one, testing PDF generation after each deactivation. Pay particular attention to plugins that also use Dompdf libraries or modify WooCommerce functionality.

Step 4: Update Custom Templates

If you're using custom PDF templates, compare them with the latest versions from the default templates. Common issues include:

  • Using deprecated methods like invoice_number() instead of number()
  • Calling methods on objects that may be null
  • Incorrect variable references

Step 5: Check Custom Code Snippets

If you've added custom code snippets to modify PDF output, review them for compatibility with the current plugin version. Common issues include:

  • Calling custom_field() on null objects
  • Using deprecated filters or functions
  • Incorrect data type handling

Step 6: Verify PHP Version Compatibility

Ensure your PHP version is compatible with the plugin. Some errors only appear in PHP 8.0+ due to stricter type checking.

Specific Solutions for Common Errors

Fixing Template Errors

For errors like "Call to a member function get_header_logo_id() on null," check that your template is properly handling the document object. Replace direct method calls with proper null checks:

// Instead of:
$logo_id = $this->get_header_logo_id();

// Use:
if ($this->get_header_logo_id()) {
    $logo_id = $this->get_header_logo_id();
}

Resolving Library Conflicts

When multiple plugins include different versions of the Dompdf library, conflicts can occur. Contact the developers of conflicting plugins to request they update their Dompdf version, or consider using alternative plugins.

Updating Deprecated Code

Replace deprecated method calls in your custom code:

  • Change invoice_number() to number()
  • Update any other deprecated methods referenced in error logs

When to Seek Further Help

If these steps don't resolve your issue, gather the following information before seeking help:

  • Complete error message from WooCommerce logs
  • Your PHP version
  • List of active plugins
  • Whether the error occurs with default templates
  • Steps to reproduce the error

Remember that template and custom code issues are common after plugin updates. Regularly reviewing and updating your custom implementations can prevent these errors from occurring.

Related Support Threads Support