• Resolved heidess

    (@heidess)


    Hello, I am currently trying to configure the custom template to include a specific field in the ‘invoice’ (editing invoice.php)

    I am using a plugin called ”WooCommerce Checkout Manager” , in which I have made multiple custom fields – the one I would like to include in the invoice is with an ID ”tr-billing_wooccm14”

    I have tried using the code snippet which I found in a discussion :

    <H3>My custom field:</H3> 
    
    <?php the_field('tr-billing_wooccm14', $this->order->get_id() ); ?>

    But it provided no results.

    Is it even possible to include such a field from a different plugin in the invoice template?

    Thanks in advance!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hi @heidess

    Check this documentation page: Displaying a custom field

    Let us know if you still have issues.

    Thread Starter heidess

    (@heidess)

    Hello,

    I tried adding the code snippet like this (in the template), but this returns parse error :

    tr-billing_wooccm14(‘tr-billing_wooccm14’, ‘My Field:’); ?>

    I don’t have a lot of knowledge in php so I might be adding something completely wrong.

    Janis

    Thread Starter heidess

    (@heidess)

    <?php $this->tr-billing_wooccm14(‘tr-billing_wooccm14’, ‘My Field:’); ?>

    Hi, I’m sorry – when originally posting the previous comment I added only a part of the snippet I used.

    Plugin Contributor dwpriv

    (@dwpriv)

    @heidess

    It seems you may have added the snippet incorrectly. Try it this way:

    <?php $this->custom_field('tr-billing_wooccm14', 'My Field:'); ?>

    Thread Starter heidess

    (@heidess)

    Hello, if I use this snippet, I don’t get the parse error anymore, but the field doesn’t show up on the invoice.

    If I use the snippet with a different (field not from the checkout plugin), it seems to work fine. (for example billing-address)

    Could the issue be that the fields generated in the checkout plugin cannot be used in the template?

    Plugin Contributor dwpriv

    (@dwpriv)

    @heidess

    Third party fields can be used across plugins so long as those fields are set to be open to use by the developers. The issue you may have here is one of syntax, meaning you may not be using the right field name.

    Sometimes with custom fields you’d need to add an underscore infront of the custom field, like this: _custom_field. So you can add the underscore in front of the custom field to see if it works.

    Also, I’m wondering if the field name you’re using may be missing an underscore of the billing, like this tr_billing_wooccm14, instead of tr_billingwooccm14?

    Thread Starter heidess

    (@heidess)

    I feel a little bit dumb now – I was using the incorrect ID for that field :

    <td><?php $this->custom_field('_billing_wooccm14', 'Kadastra numurs:'); ?></td>

    This worked for me!

    Thanks a lot for the great support!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom fields in template’ is closed to new replies.