• Resolved Make carlos

    (@make-carlos)


    Hi
    I want to send different PDF in email with different text for example i have two types of payment method like: Request only and paypal.

    So if user have done with request quote then i need to show different text in PDF. here is code example.

    
    $method = $this->payment_method();
    if( $method == 'Request Quote only' ) {
    ?>
    <h1 class="document-type-label">Quote</h1>
    <?php
    }else{
    ?>
    <h1 class="document-type-label">
    <?php if( $this->has_header_logo() ) echo $this->get_title(); ?>
    </h1>
    <?php } ?>

    but its only echo the text that is Request Quote only and nothing happen in PDF text.

    Thanks
    Make

    • This topic was modified 4 years, 1 month ago by Make carlos.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hello Make,
    The function $this->payment_method() does not have a return value, it’s a display function. If you want to get the text in a string you can use $this->get_payment_method() instead.

    For reliability it’s probably better to call the WooCommerce function, this will give you the internal name (which does not change) rather than the name as presented to the customer (which can be changed). You can use

    
    $method = $order->get_payment_method();
    

    To see what the name of these methods are you can (temporarily) print it in the PDF:

    
    echo $method;
    
    Thread Starter Make carlos

    (@make-carlos)

    Hi

    Yes perfect but i have fixed it different way. here is code.

    add_filter( 'wpo_wcpdf_invoice_title', 'wpo_wcpdf_invoice_title', 10, 2 );
    function wpo_wcpdf_invoice_title ( $title, $document = null ) {
    if (!empty($document) && !empty($document->order)) {
    if ( $document->order->get_payment_method() === 'other_payment' ) {
    $title = 'Quote';
    }
    }
    return $title;
    }

    This will helps other ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Different text in Inovice’ is closed to new replies.