• Resolved magick207

    (@magick207)


    Hello,

    I read this page https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/displaying-a-custom-field/, but I can’t display the custom field.
    I want to show the custom field below the Payment method. I add this code

    <tr class="custom-field">
    <th><?php _e( 'Custom field:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
    <td><?php $this->conf_info_bdg_affil('conf_info_bdg_affil', 'Custom field:'); ?></td>
    </tr>

    where conf_info_bdg_affil is my field name that there is in the order backend. But when I create the pdf I have an error

    Fatal error: Call to undefined method WPO\WC\PDF_Invoices\Documents\Invoice::conf_info_bdg_affil()

    Can you help me?

    • This topic was modified 2 years, 1 month ago by magick207.
    • This topic was modified 2 years, 1 month ago by magick207.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @magick207:

    You have used conf_info_bdg_affil not only as a meta key, but also as a method, that is a class function that do not actually exists within the code base.

    That said, please try with this code snippet instead:

    <tr class="custom-field">
    <th><?php _e( 'Custom field:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
    <td><?php $this->custom_field( 'conf_info_bdg_affil' ); ?></td>
    </tr>
    Thread Starter magick207

    (@magick207)

    Hi @yordansoares,

    it works, but now I have 2 field: one called “Custom field” and one called with the my field name.

    Thank you.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Not sure if I’m understanding correctly, but please note that the code you posted need to be replaced with the one I shared above.

    Thread Starter magick207

    (@magick207)

    Yes, I replaced it. In any case the original post was my mistake. Sorry and thank you again for your support.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    There is nothing to apology, @magick207: We are always happy to help! 🙂

    If you don’t mind and have the time, do you think you could leave us a review?

    Thanks in advance and all the best with your store!

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

The topic ‘Add custom fields’ is closed to new replies.