• Resolved muelliman

    (@muelliman)


    Hi there,

    I am using this action to add conditional informations to the invoice.

    
    add_action( 'wpo_wcpdf_after_order_details', 'wpo_wcpdf_custom_text', 10, 2 );
    function wpo_wcpdf_custom_text ($template_type, $order) {
        $payment_method = $order->get_payment_method();
        if ($template_type == 'invoice' && $payment_method == 'bacs') {
            ?>
            <div class="zahldaten">
    	Text, Text, Text....<br>
             -- Invoice Number here --
            </div>
            <?php
        } elseif ($template_type == 'invoice' && ($payment_method == 'stripe' || $payment_method == 'paypal') )  {
        echo "Der Rechnungsbetrag wurde bereits dankend erhalten.";
        }
    }

    I wanted to output also the invoice number like <?php $this->invoice_number(); ?>in the text of this condition

    how can I integrate it? just using the snippet like $this->invoice_number(); does not work.

    thanks, Pascal

    • This topic was modified 4 years, 7 months ago by muelliman.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hello @muelliman

    Try this:

    add_action( 'wpo_wcpdf_after_order_details', 'wpo_wcpdf_custom_text', 10, 2 );
    function wpo_wcpdf_custom_text ($template_type, $order) {
    	$payment_method = $order->get_payment_method();
        if ($template_type == 'invoice' && $payment_method == 'bacs') {
    		$document = wcpdf_get_document( $template_type, $order );
            ?>
            <div class="zahldaten">
    			Text, Text, Text....<br>
    			<?= $document->invoice_number(); ?>
            </div>
            <?php
        } elseif ($template_type == 'invoice' && ($payment_method == 'stripe' || $payment_method == 'paypal') )  {
        echo "Der Rechnungsbetrag wurde bereits dankend erhalten.";
        }
    }

    Let me know.

    Thread Starter muelliman

    (@muelliman)

    Hello @alexmigf

    Thanks a lot, this works like a charm!

    Pascal

    Plugin Contributor alexmigf

    (@alexmigf)

    You’re welcome ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘action hook in functions with invoice number’ is closed to new replies.