• Resolved sunnylife

    (@sunnylife)


    I am using this plugin to generate automated invoices. But unfortunately 2 of my checkout form fields i.e. “Alternate Phone No” and “Landmark” are going to missed in the invoice.

    Please help me. [sabziadda.com]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hello @sunnylife,

    You can add custom fields to your invoices using the template action hooks. See several examples about adding new fields to your invoices here.

    Let’s say your custom field is stored with the order meta key alternate_phone_number, then you could add this field to your invoices using the following code snippet:

    add_action( 'wpo_wcpdf_after_billing_address', 'wpo_wcpdf_delivery_date', 10, 2 );
    function wpo_wcpdf_delivery_date ($template_type, $order) {
        $document = wcpdf_get_document( $template_type, $order );
        if ($template_type == 'invoice') {
            ?>
            <tr class="alternate-phone-number">
                <th>Alternate phone number:</th>
                <td><?php $document->custom_field('alternate_phone_number'); ?></td>
            </tr>
            <?php
        }
    }

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

    You can also add any field, without no code, using Premium Templates. This extension includes a customizer that allows you to tailor your PDF documents using product columns, total rows, and custom blocks. In addition, Premium Templates provides two additional templates: Business and Modern.

    For your specific case, you only need to add a custom, block this way:

    A screenshot that display an use example of the custom blocks

    Then, your invoices will display your custom field:

    A screenshot that display the example custom field on the invoice

    If you don’t know the name of your custom field, see Finding WooCommerce custom fields

    Let me know if you have more questions ??

    Thread Starter sunnylife

    (@sunnylife)

    sir i added your suggested code but it breaks my invoice alignment. Alternate no is displaying too right. Email and phone number too below and invoice details alignment also changed.

    Please check the attached issue here. https://pasteboard.co/K1FO5Wg.jpg

    I just want to print “Alternate phone no” and “landmark” just below the billing details.

    Thank you.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Sorry for the mistake.

    Please replace my previous code snippet for this one:

    add_action( 'wpo_wcpdf_after_billing_address', 'wpo_wcpdf_delivery_date', 10, 2 );
    function wpo_wcpdf_delivery_date ($template_type, $order) {
    	$document = wcpdf_get_document( $template_type, $order );
    	if ($template_type == 'invoice') {
    		?>
    		<div class="alternate-phone-number">
    			<p>
    				<span>Alternate phone number:</span>
    				<?php $document->custom_field('alternate_phone_number'); ?>
    			</p>
    		</div>
    		<?php
    	}
    }

    Let me know if it works ??

    Thread Starter sunnylife

    (@sunnylife)

    Sir, it works to print “Alternate Phone No”. But, it overwrite my existing form field i.e. “Complete Street Address” which is very important.

    So, please take a moment to get rid of this issue as well.

    Thread Starter sunnylife

    (@sunnylife)

    sorry it works. thank you for support.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    I’m glad to know you managed to display your custom fields ??

    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 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Alternate Phone No & Landmark Missing in Invoice’ is closed to new replies.