• Resolved bvkumar2602

    (@bvkumar2602)


    Hello,

    I m trying to display a custom field of product HSN CODE to the invoice pdf.

    I created a custom field using ACF in product and trying to show that custom field of product in my pdf invoice.

    How can i do that please help.

    Thanks,

    Vijay

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

    (@pomegranate)

    Hello Vijay,
    There are two ways to do this:

    1) With the free plugin you can follow this guide: Displaying product custom fields

    2) With the Premium Templates extension you can do this without code, using the “Custom field (Product)” column:

    Or printing it below the product name using the {{product_custom_field::META_KEY}} placeholder (Where you replace META_KEY with the key for the field)

    Thread Starter bvkumar2602

    (@bvkumar2602)

    I m using the free plugin.

    Can you please help me with the code. I will really appreciate your help.

    Thanks,

    Vijay

    Plugin Contributor Ewout

    (@pomegranate)

    Instructions for the free plugin are linked in my previous post, the first suggestion:

    1) With the free plugin you can follow this guide: Displaying product custom fields

    Thread Starter bvkumar2602

    (@bvkumar2602)

    I tried it but it still not showing up.

    Plugin Contributor alexmigf

    (@alexmigf)

    Hello @bvkumar2602

    Please try this:

    add_action( 'wpo_wcpdf_after_item_meta', 'wpo_wcpdf_print_acf_field', 10, 3 );
    function wpo_wcpdf_print_acf_field ( $template_type, $item, $order )
    {
        if ( !empty($order) && $template_type == 'invoice' ) {
            ?>
            <div class="hsn-code">
                <strong>HSN Code:</strong>
                <?php the_field( 'hsn-code', $item['product_id'] ); ?>
            </div>
            <?php
        }
    }

    The hsn-code must be your ACF field name.

    If you never worked with actions/filters before, please read this documentation page.

    Let me know.

    Thread Starter bvkumar2602

    (@bvkumar2602)

    I replaced the code with my field name my ACF field name hsncode

    Still not working. I installed that code in my function.php file.

    Thread Starter bvkumar2602

    (@bvkumar2602)

    I m using the wrong ACF plugin ? Is that something causing the issue

    Plugin Contributor alexmigf

    (@alexmigf)

    Hello @bvkumar2602

    Can you show me the code you used please?

    Thread Starter bvkumar2602

    (@bvkumar2602)

    add_action( ‘wpo_wcpdf_after_item_meta’, ‘wpo_wcpdf_print_acf_field’, 10, 3 );
    function wpo_wcpdf_print_acf_field ( $template_type, $item, $order )
    {
    if ( !empty($order) && $template_type == ‘invoice’ ) {
    ?>
    <div class=”hsncode”>
    HSN Code:
    <?php the_field( ‘hsncode’, $item[‘product_id’] ); ?>
    </div>
    <?php
    }
    }

    Plugin Contributor alexmigf

    (@alexmigf)

    Hello @bvkumar2602

    Something is not quite right there, please send us an email, we will do our best to help you.

    Thread Starter bvkumar2602

    (@bvkumar2602)

    what should i send you in the email?

    Plugin Contributor alexmigf

    (@alexmigf)

    Thread Starter bvkumar2602

    (@bvkumar2602)

    Okay sent you an email just now.

    Plugin Contributor alexmigf

    (@alexmigf)

    Was fixed with the last script posted in this topic.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Cant we show custom field from product to invoice pdf?’ is closed to new replies.