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
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
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.
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://ww.wp.xz.cn/support/topic/add-custom-front-end-field-to-the-pdf/
Thanks, it works, but only if I send with my form and not with the download pdf button. How can I replace the button
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
Oh, great! It works!
Thank you very much!