• Resolved tvlaamsstripcentrum

    (@tvlaamsstripcentrum)


    Hi
    With Flexible Checkout Fields I created an extra text field Lidnummer. With meta name: _shipping_lidnummer. I want to add this extra field to the PDF Invoices & Packing Slips for WooCommerce but I can’t seem to find the right hook to load _shipping_lidnummer in the e-mail template, like explaind here. I’m guessing I’m missing something.

    If I take a look at how the payment_method is loaded:

    <?php if ( $payment_method = $this->get_payment_method() ) : ?>
    				<tr class="payment-method">
    					<th><?php _e( 'Betaald met:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
    					<td><?php echo $payment_method; ?></td>
    				</tr>
    				<?php endif; ?>

    But when I try to get the _shipping_lidnummer I get an error.
    I was thinking that this should work:

    <?php if ( $lidnummer = $this->get_shipping_lidnummer() ) : ?>
    				<tr class="lidnummer">
    					<th><?php _e( 'Lidnummer:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
    					<td><?php echo $lidnummer; ?></td>
    				</tr>
    				<?php endif; ?>

    Is there an other way to load the extra field?

Viewing 1 replies (of 1 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hi @tvlaamsstripcentrum

    You’re calling the function $this->get_shipping_lidnummer() which doesn’t exist in our plugin, that’s why you’re seeing an error. You don’t need to change the current template or create a custom one, just add the code snippet below:

    add_action( 'wpo_wcpdf_after_order_data', function( $document_type, $order ) {
    	if ( $document_type == 'invoice' && ! empty( $order ) ) {
    		?>
    		<tr class="lidnummer">
    			<th>Lidnummer:</th>
    			<td><?php echo $order->get_meta('_shipping_lidnummer'); ?></td>
    		</tr>
    		<?php
    	}
    }, 10, 2 );

    If you never worked with actions/filters please read this documentation page: How to use filters

Viewing 1 replies (of 1 total)
  • The topic ‘Displaying a custom field from Flexible Checkout Fields’ is closed to new replies.