• Resolved schoefl

    (@zemekis148)


    When loading my custom template from the child theme I get the error:

    Fehler beim Versuch, ein Dokument zu erzeugen: wcpdf_get_document(): Argument #1 ($document_type) must be of type string, null given, called in …/httpdocs/wp-content/themes/{CHILD-THEME}/woocommerce/pdf/{NAME}/invoice.php on line 7

    Even if the original files are used without any adjustments.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @zemekis148,

    Please go to WooCommerce?> PDF?Invoices?> General?> Choose?a?template and temporarily change the template to Simple, and try to open a generated PDF to see if it opens correctly.

    Thread Starter schoefl

    (@zemekis148)

    Loading the Simple template works.

    Plugin Contributor dwpriv

    (@dwpriv)

    Thanks for your follow up @zemekis148 . We will mark this topic as resolved

    Thread Starter schoefl

    (@zemekis148)

    This Problem is not resolved! Please I need help.

    Loading a template from the child theme is still not possible.

    Plugin Contributor dwpriv

    (@dwpriv)

    @zemekis148 do you still get the same error?

    Thread Starter schoefl

    (@zemekis148)

    I was now able to isolate the problem. I have the following code in my template in invoice.php to show extra fields:

    <?php
     $settings_general = get_option( 'wpo_wcpdf_settings_general' );
     $document = wcpdf_get_document( $template_type, $order );
     $items = $order->get_items();
     $custom_field_1 = '';
     $custom_field_2 = '';
     $custom_field_3 = '';
     foreach ( $items as $item ) {
      $product_id1 = $item['product_id'];  
      if ( has_term( 'werbemittel', 'product_cat', $product_id1 ) ) {
       $custom_field_1 = '<p>' . $this->get_settings_text( 'extra_1' ) . '</p>';
       continue;
       }
      }
     foreach ( $items as $item ) {
      $product_id = $item['product_id'];  
      if ( has_term( 'buchung', 'product_cat', $product_id ) ) {
       $custom_field_2 = '<p>' . $this->get_settings_text( 'extra_2' ) . '</p>';
       continue;
       }
      }
     foreach ( $items as $item ) {
      $product_id = $item['product_id'];  
      if ( has_term( 'mitgliedsbeitrag', 'product_cat', $product_id ) ) {
       $custom_field_3 = '<p>' . $this->get_settings_text( 'extra_3' ) . '</p>';
       break;
       }
      }
     ?>
    

    These lines come before <table class=”head container”>. That worked for years, but not anymore. Can you please tell me how to properly display an additional field.

    Plugin Contributor dwpriv

    (@dwpriv)

    @zemekis148 it seems you’re trying to display a product custom field. You can use this guide as an example of how to go about it using filters. There is also a section with an example snippet of printing the product custom fields in a custom template.

    Thread Starter schoefl

    (@zemekis148)

    Thank You @dwpriv!

    Plugin Contributor dwpriv

    (@dwpriv)

    no problem, @zemekis148 I will mark this topic as closed. Feel free to reopen it if you find the issue persists after your changes

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Error after Update’ is closed to new replies.