Support » Plugin: WooCommerce PDF Invoices & Packing Slips » Cannot add new field to template

  • Resolved marlonsabala

    (@marlonsabala)


    hey guys,

    I’ve tried to follow your instructions to add an extra field (if the user did fill it) on the invoice.

    add_filter( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_add_NIF', 10, 2 );
    function wpo_wcpdf_add_tax_id( $template_type, $order ) {
    	if ( $template_type == 'invoice' ) {
    		echo "<tr><td>This should</td><td>print no matter what</td></tr>";
    		$nif = $order->get_meta( 'billing_nif' );
    		if ($nif) {
    			echo "<tr><td>NIF / NIPC:</td><td>{$nif}</td></tr>";
    		}
    	}
    }

    This is what I have, but nothing comes up. I delete and recreate the PDF but no luck.

    Is there something I’m missing?

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

    (@pomegranate)

    your function name and filter callback don’t match: wpo_wcpdf_add_NIF vs wpo_wcpdf_add_tax_id.

    marlonsabala

    (@marlonsabala)

    That was pretty silly. thanks.

    Unfortunately it still doesnt seem to do anything.

    add_filter( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_add_NIF', 10, 2 );
    function wpo_wcpdf_add_NIF( $template_type, $order ) {
    	if ( $template_type == 'invoice' ) {
    		echo "<tr><td>This should</td><td>print no matter what</td></tr>";
    		$nif = $order->get_meta( 'billing_nif' );
    		if ($nif) {
    			echo "<tr><td>NIF / NIPC:</td><td>{$nif}</td></tr>";
    		}
    	}
    }
    Plugin Author Ewout

    (@pomegranate)

    Is that not printing the “This should” line either? Where did you put this filter exactly? Are you sure you are using “WooCommerce PDF Invoices & Packing Slips”, version 2.3.5?

    marlonsabala

    (@marlonsabala)

    Got it! Another silly mistake.

    Thanks for your help.

    Plugin Author Ewout

    (@pomegranate)

    wpo_wcpdf_after_order_data is an action, can you try using add_action instead? Note that this is restricted to the Invoice too. Other than that, I have no idea either…

    marlonsabala

    (@marlonsabala)

    Thanks again,

    Is there a way of getting it to show under the user details instead of on the right side?

    Plugin Author Ewout

    (@pomegranate)

    marlonsabala

    (@marlonsabala)

    Perfect!

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.