Custom Additional Checkout Field Not Adding to PDF invoice using code snippet
-
Hello. I’m using this plugin on my site, https://carsonscookiefix.com, along with the Woocommerce PDF Invoice & Packing Slips plugin (https://www.ads-software.com/plugins/woocommerce-pdf-invoices-packing-slips/). I’m trying to add the Checkout Manager additional fields to my pdf invoice using code snippets. I’ll begin by saying I’ve spent hours trying to troubleshoot this myself and searching the forums. Nothing I found worked. Also, I want to mention that this previously worked and it was just recently where it stopped working. It looks like the code in the invoice.php file changed which must have caused the issue. Previously, the below code snippet worked when added to the invoice.php file located in /wp-content/plugins/woocommerce-pdf-invoices-packing-slips/templates/Simple:
<?php $wpo_wcpdf->custom_field(‘myfield3’, ‘Order Notes:’); ?>
(I added this after the after_order_details section in the php file)
It seems as though the code changed per the documentation found in this link (https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/displaying-a-custom-field/), and so the below code snippet is now what should be added:
<?php $this->custom_field(‘myfield3’, ‘Order Notes:’); ?>
This does not work. I tried adding it to the invoice.php file within the plugin files and also by creating a custom template in my child theme folder, as well as the main theme folder. Nothing worked. I enabled the debug output, and this is the notice I get in the PDF:
Notice: Use of undefined constant ‘myfield3’ – assumed ‘‘myfield3’’
in /www/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/templates/Simple/invoice.php on line 139I tried adding simple text “test” in place of the snippet and the output worked fine. So it seems as though it does not like the html I am adding.
Please note, I also attempted the below snippets which also did not work:
<?php $this->custom_field(‘_myfield3’, ‘Order Notes:’); ?>
<?php $this->custom_field(‘myfield3’); ?>
<?php $this->custom_field(‘additional_myfield3’, ‘Order Notes:’); ?>
<?php $this->custom_field(‘_additional_myfield3’, ‘Order Notes:’); ?>
<?php $this->custom_field(‘_billing_myfield3’, ‘Order Notes:’); ?>
<?php custom_field(‘myfield3’); ?>
<?php $this->custom_field(‘_custom_myfield3’); ?>
<?php $this->custom_field(‘custom_myfield3’); ?>I probably tried more than that but that’s all I can remember. I tried them all within the plugin and theme files.
I also installed the plugin Woocommerce Store Toolkit (https://www.ads-software.com/plugins/woocommerce-store-toolkit/) to ensure I was using the right custom field meta tag. It confirmed that the meta tag should simply be “myfield3”.
I’m using all current versions of my theme, WordPress, plugins, and WooCommerce. My memory limit is set at 256M.
What am I missing? I don’t understand why it was working previously and now it isn’t. Thank you in advance for your help.
The page I need help with: [log in to see the link]
- The topic ‘Custom Additional Checkout Field Not Adding to PDF invoice using code snippet’ is closed to new replies.