Title: Call function from function.php
Last modified: April 18, 2021

---

# Call function from function.php

 *  Resolved [admt2018](https://wordpress.org/support/users/admt2018/)
 * (@admt2018)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/call-function-from-function-php/)
 * Hi, I have inserted a function in the function.php file that allows me to type
   some text in the cart. I would now like to be able to view it in the pdf. The
   function is:
 *     ```
       add_action('woocommerce_before_cart_contents', 'tf_cart_page_custom_text');
   
       function tf_cart_page_custom_text() {
   
           $message='<div class="cart-custom-message">';
               $message.='<h2>Intestazione</h2>';
               $message.='<p align="justify"><textarea></textarea>';
           $message.='</div>';
   
           echo $message;
       }
       ```
   
 * Can you help me?ù
    Thank you
    -  This topic was modified 5 years, 1 month ago by [admt2018](https://wordpress.org/support/users/admt2018/).

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Thread Starter [admt2018](https://wordpress.org/support/users/admt2018/)
 * (@admt2018)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/call-function-from-function-php/#post-14335217)
 * Isn’t this problem interesting enough? I have searched through the topics but
   there is nothing that can help me. Should I consider not receiving support? Thank
   you
 *  Plugin Author [David Jensen](https://wordpress.org/support/users/dkjensen/)
 * (@dkjensen)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/call-function-from-function-php/#post-14336900)
 * Apologies for the delay in response, could you try to override the PDF template
   and then add in the custom content you would like?
 * Copy the PDF template from the plugin folder wc-cart-pdf/templates/cart-table.
   php into your child theme folder child-theme/woocommerce/wc-cart-pdf/cart-table.
   php
 * Then edit the cart-table.php in your child theme
 * Let me know if this works for you
 *  Thread Starter [admt2018](https://wordpress.org/support/users/admt2018/)
 * (@admt2018)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/call-function-from-function-php/#post-14337451)
 * No problem, thanks for the reply. Now I have inserted a function in the function.
   php that generates a form in the cart that allows me to print a free text. The
   form is printed on the pdf but I cannot print its content
    I’ll report the codes
   used: The first is the function written in function.php
 *     ```
       add_action('woocommerce_before_cart_contents', 'tf_cart_page_custom_text');
   
       function tf_cart_page_custom_text() {
   
           $message='<div class="cart-custom-message">';
               $message.='';
               $message.='<form action="" method="post">
       <label>Cliente:</label><br>
       <textarea cols="35" rows="12" name="comments" id="para1">
       </textarea><br>
       <input type="submit" name="button" value="Invia"/></form>';
           $message.='</div>';
   
   
           echo $message;
       }
       ```
   
 * this, on the other hand, is the code inserted in the cart-table.php that regularly
   prints me all the contents of $ message
 *     ```
       do_action( 'woocommerce_before_cart_contents', 'tf_cart_page_custom_text' );
       if ( file_exists( $message ) ) {
       echo $message;	
       	}
       ```
   
 * To make the form work I entered `$ comments = $ _POST ['comments'];` and `echo"
   Current header:". "<br>". $ comments;`
 * But in the pdf I only see the form without the content of $comments.
 * Could you help me? Thank you very much
    -  This reply was modified 5 years, 1 month ago by [admt2018](https://wordpress.org/support/users/admt2018/).
 *  Plugin Author [David Jensen](https://wordpress.org/support/users/dkjensen/)
 * (@dkjensen)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/call-function-from-function-php/#post-14337501)
 * Why are you checking if a file exists, are you saving contents to a file?
 * If you just want a field on your cart and then when the form is submitted the
   field displays on PDF, try something like this:
 * [https://wordpress.org/support/topic/add-custom-front-end-field-to-the-pdf/](https://wordpress.org/support/topic/add-custom-front-end-field-to-the-pdf/)
 *  Thread Starter [admt2018](https://wordpress.org/support/users/admt2018/)
 * (@admt2018)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/call-function-from-function-php/#post-14337640)
 * Thanks, it works, but only if I send with my form and not with the download pdf
   button. How can I replace the button
 *  Plugin Author [David Jensen](https://wordpress.org/support/users/dkjensen/)
 * (@dkjensen)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/call-function-from-function-php/#post-14337673)
 * You can remove the original button using this code:
 *     ```
       remove_action( 'woocommerce_proceed_to_checkout', 'wc_cart_pdf_button', 21 );
       ```
   
 * Then just style your new form submit button as you would like
 *  Thread Starter [admt2018](https://wordpress.org/support/users/admt2018/)
 * (@admt2018)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/call-function-from-function-php/#post-14340600)
 * Oh, great! It works!
    Thank you very much!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Call function from function.php’ is closed to new replies.

 * ![](https://ps.w.org/wc-cart-pdf/assets/icon-256x256.png?rev=3339735)
 * [Cart PDF for WooCommerce](https://wordpress.org/plugins/wc-cart-pdf/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wc-cart-pdf/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wc-cart-pdf/)
 * [Active Topics](https://wordpress.org/support/plugin/wc-cart-pdf/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wc-cart-pdf/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wc-cart-pdf/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [admt2018](https://wordpress.org/support/users/admt2018/)
 * Last activity: [5 years, 1 month ago](https://wordpress.org/support/topic/call-function-from-function-php/#post-14340600)
 * Status: resolved