• Hi, at the first sorry about my english… i am from spain and can not speak english so good… well, i am trying to show cif on pdf invoice using WooCommerce PDF Invoices & Packing Slips plugin. I copied files to theme pdf folder and now i do not know what line and where i must to include de custom field CIF…

    In woocommerce check out forms, in billing fields, i added a new field called CIF, so now, when i do a purchase, system ask to me obligatory for CIF, but obisuly after it do not show in pdf because i need to modify one or more lines in templates from wp-content/themes/mango/woocommerce/pdf/factura/*.*

    plesase, can somebody help me, thanks in advance and best regards

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi! If you know the meta key / field name of the CIF field, you can go straight to this page for instructions.
    Displaying a custom field

    If you’re not sure about the meta key, go here first.
    Finding WooCommerce Custom Fields

    Hope that helps!
    Ewout

    Thread Starter macauty

    (@macauty)

    Oh my God!! this is so dificult to me… between code and english… I knok the meta key / field name, i think i know because it has been created by me in Woocommerce/checout forms/billing fields:

    meta

    and now i have got this files that i have copied to wp-content/themes/mango/woocommerce/pdf/factura/*.*

    files

    and finaly i know that i need to insert code in invoice.php, but i do not understand what and where…..

    invoice.php

    please… more help to me???? Thanks so much!!!

    Plugin Contributor Ewout

    (@pomegranate)

    Hi! Your pictures do not work. Maybe upload them to imgur.com?
    If you need an easier solution, I recommend the Professional extension, so that you don’t need to change the template.

    Ewout

    Thread Starter macauty

    (@macauty)

    Hi Ewout,

    here you are pictures: https://imgur.com/a/e9MiH

    I have already thinked in the Professional extension. But I am starting and sincerly i am trying to low cost. I can use free template, i only need to show CIF (in spain’s invoices are obligatory). If finaly i can not insert the correct line in the correct place in invoice.php to solve this, i will purchase it. So, please if you, or somebody can help me, would be great, else, thank you so much for your help boys…

    Plugin Contributor Ewout

    (@pomegranate)

    Hi,
    Thanks for sending that. If you could include a screenshot from the WooCommerce Store Toolkit (from the Finding WooCommerce Custom Fields guide from above, I may be able to help. You don’t need to create a custom template if you just use the template action hook as described on the documentation page about custom fields.

    The action will then look something like this

    
    add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_billing_cif', 10, 2 );
    function wpo_wcpdf_billing_cif ($template_type, $order) {
        global $wpo_wcpdf;
        ?>
        <tr class="billing-cif">
            <th>CIF:</th>
            <td><?php $wpo_wcpdf->custom_field('billing_cif'); ?></td>
        </tr>
        <?php
    }
    

    where the billing_cif field should match the field name, except for a leading underscore (i.e. _billing_cif becomes billing_cif).

    This goes into your child theme functions.php or code snippets: How to use filters. Note that if you use this filter, you don’t need a custom template altogether!

    Hope that helps
    Ewout

    Thread Starter macauty

    (@macauty)

    Ewout… thank you so so much!

    I added code to the end in functions.php but CIF does not appear in pdf… I don not have Store tool kit… I do not know how much can i do to you for help me…

    Thread Starter macauty

    (@macauty)

    Hi again Ewout…

    sorry but your code works correctly!!! Only that i did not see the field CIF in my test… but now i already see it and it’s perfect!! so…… THANK YOU SO MUCH Ewout!! Sincery, thanks!!!

    Best regards from the south of Spain!!

    Plugin Contributor Ewout

    (@pomegranate)

    Great, glad to hear it all works now! The WooCommerce Store Toolkit is a free plugin and very useful if you’re doing customizations like this. The Finding WooCommerce Custom Fields guide describes this in detail.

    Have a great day!
    Ewout

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘CIF on pdf’ is closed to new replies.