• Resolved bestplaced

    (@bestplaced)


    Is it possible to change the invoice template, based on the order payment method? I want to use two invoice templates – one for Klarna and one template for the rest of the payment menthods. Is this possible?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor kluver

    (@kluver)

    Hi @bestplaced,

    You could create a custom template for your invoice and create a div around your whole document that has a class based on which payment method is being used.

    Then based of that class you can show or hide certain elements with CSS in your document. For instance checking if the payment method is cash on delivery:

    <?php $payment_method = $this->order->get_payment_method(); ?>
    <div class="<?php echo $payment_method == 'cod' ? 'cod' : 'not-cod'; ?>">
        //YOUR TEMPLATE HERE
    </div>

    I hope this helps!

    • This reply was modified 8 years ago by kluver.
    • This reply was modified 8 years ago by kluver.
    Thread Starter bestplaced

    (@bestplaced)

    Ok, sounds good. Thank you. Do you have any Idea where i can get/find the “codes” for the payments, like “cod”? Thanks

    Plugin Contributor Ewout

    (@pomegranate)

    Hi! These codes used to be listed in the WooCommerce settings, under “Checkout” (in the “Gateway ID” column), but WooCommerce changed that with the 3.4 update. If You have already updated to 3.4, the easiest place you can find this now is by checking the url of the settings page if you go to WooCommerce > Settings > Payments > [your payment method] and then check the “&section=xxx” bit in the url (where xxx is your code).

    Good luck!
    Ewout

    Thread Starter bestplaced

    (@bestplaced)

    Works like a charm! Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Change Template based on Payment Method’ is closed to new replies.