Viewing 6 replies - 16 through 21 (of 21 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hello Michal,
    You can just type “NIP (do factury VAT):” in front of the code, it’s as simple as that :o)
    If you only want to display the label when the field data is present, you can use a slightly altered code snippet:

    <?php
    $nip = get_post_meta($wpo_wcpdf->export->order->id,'NIP (do fakury VAT)',true);
    if (isset($nip)) {
    	echo 'NIP (do factury VAT): ' . $nip;
    }
    ?>

    I disagree with you that the function is NOT AVAILABLE in the plugin. I am not asking you to modify any core files, I have created a templating system that allows to you create a custom template completely to your liking. This is quite different from adding functionality to the plugin.
    You don’t need programming skills to add the custom fields code, just some basic knowledge of HTML and a text editor. You type text like you normally would in a document, and add the code snippets where you want the custom fields to appear.

    What you propose is very complex to implement, programming wise, because there are many possible locations and formatting for these custom fields in the invoice. Moreover, it would impede the flexibility that the custom templating system currenly offers, because there would be much more code in the template. This is a choice I made, the template flexibility is a very important aspect of the plugin that also sets it apart from other PDF plugins on the market.

    That said, I agree with you that it would be nice to be able to add a custom field as easy as you suggest. I am tinkering with the idea to create a template editor that you can install besides the main plugin, and I think this would meet your wish to alter the contents of the invoices and packing slips more easily, while still maintaining the basic template flexibility of the plugin.

    Plugin Contributor Ewout

    (@pomegranate)

    I have a little surprise for you. I added a function that makes displaying a custom field a little bit more simple. If you update to the latest version of the plugin (1.4.3) you can use the following code:

    <?php $wpo_wcpdf->custom_field('NIP (do fakury VAT)', 'NIP (do fakury VAT):'); ?>

    The plugin only displays the field when it contains data. If you also want to display the label when the field is empty, you can pass a third parameter (true), like this:

    <?php $wpo_wcpdf->custom_field('NIP (do fakury VAT)', 'NIP (do fakury VAT):',  true); ?>

    OK, thanks for explanations ??

    Your idea about template editor sounds great! ??

    I’ll adjust the code as you suggested.

    One thing is sure: this plugin has INCREDIBLE SUPPORT :D. You rock! ??

    Ooooo! Thanks man!

    Showing this field only when there are data in it is exactly what I need, because custom fields are optional, but important for some.

    GREAT! ??

    Plugin Contributor Ewout

    (@pomegranate)

    Just for anyone reading this and trying to do the same, I’m copying the text that is now included in the FAQ too:

    How can I display custom fields in the invoice or packing slip?
    First, you need to create a custom template following instructions from the first item in this FAQ. Then place the following snippet where you would like the custom field to appear:

    <?php $wpo_wcpdf->custom_field('custom_fieldname', 'Custom field:'); ?>

    Where you replace ‘custom_fieldname’ with the name of the field you want to display, and ‘Custom field’ with the label. The plugin only displays the field when it contains data. If you also want to display the label when the field is empty, you can pass a third parameter (true), like this:

    <?php $wpo_wcpdf->custom_field('custom_fieldname', 'Custom field:',  true); ?>

    Thank you for this post! I followed it and finally managed to fix my problem. Love your plugin!

Viewing 6 replies - 16 through 21 (of 21 total)
  • The topic ‘add fields in the simple template from WooCommerce Checkout Manager’ is closed to new replies.