Hello,
I have searched but I could not find any proper result. Is there any way to show payment method of order in invoice, can we add some codes/function to commerce billy's tpl file?

thank you.

Comments

alibama’s picture

just did this = make a relationship to the order, then a relationship to your payment transaction in the line item, then add the message field

yenidem’s picture

@alibama, Commerce Billy does not use views so how can I add relationship? Do I have to add using with code to tpl page?

alibama’s picture

oh - i was using commerce_billy_pdf and that does use views....

yenidem’s picture

I use commerce billy PDF too, it is not use views, there is a template file. The other project Commerce PDF Invoice use views :)

alibama’s picture

nope, I'm using billy pdf and it uses the line item view to create the invoice /admin/structure/views/view/commerce_line_item_table/edit is the view i'm working from

yenidem’s picture

Thank you alibama, I did as you said and it works. But the payment method showing per line item instead of whole order, however we need to see payment method for accounting department. this meet our requirement.

yenidem’s picture

Status: Active » Fixed
alibama’s picture

use tokens in the view header and you'll be done = since it's the same on every row the view header (or footer) is the simplest way to fix this

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

giosko’s picture

Hello guys i have the same issues but i really do not understand what i have to do in views!
Can you help me by giving more information? Or also screenshots?
I have understand that i have to do something in the specific view, that you are talking about, but i do not understand what! :)

Thanks!

giosko’s picture

I re-opened the issue at https://www.drupal.org/node/2487259 because your fix does not seems to work.
Any help will be appreciated.

Thanks.

liam.dupin’s picture

I did what alibama described and it works well. In Line items (Commerce line item) view you have to add relationship (under Advanced) Commerce Line Item: Order ID and Commerce Order: Payment Transaction (in settings you have to choose relation to identifier of previously added relationship). Then you will add the field Commerce Payment Transaction: Payment method with relation set to the latter relationship and check not to display this field. In header (or footer) you will add Global: Text area and use token in it - [payment-method].

MariskaTh’s picture

liam.dupin Thank you for your explanation. I tried to follow all the steps. However, when I look at the invoices now it says: 'no line items found'. The prices are displayed perfectly anyway.

I'm working on my localhost with an example payment. Could that be a problem?

Or do you have an other idea what could be wrong?

Thanks,
Mariska.

tzt20’s picture

I just figured this one out. Thank you all for documenting your processes along the way.

Essentially, you'll need to add the relationships:
Commerce Line Item: Order ID
Commerce Order: Payment Transaction

Remember, do not require either relationships.

In order to have the token available for the header or footer, add the payment method type to the field list. Add Commerce Payment Transaction: Payment Method and exclude it from display. Also don't forget to select "A short version of the title safe to display to all" under the field configuration.

Now, add a Global: Text Area footer with the token. Note: You should select "Use replacement tokens from the first row" and then add your text.
Selected payment method:
[payment_method]

fotograafinge’s picture

Thanks for the summary in #14

I see the paymentmethod in the Invoice PDF. But ... my line-items don't show anymore in the order confirmation emails.

MariskaTh’s picture

Hello tzt20,

Thanks for your clear explanation. It does work now.

However, the payment method now appears below the line-items, above the subtotal. That looks a bit strange.

Is there a way to show the payment method below the "Total order"?

Best regards,
Mariska.

tzt20’s picture

@fotograafinge
I believe you need to disable SQL rewriting to get it working properly. There's a thread on that here: https://www.drupal.org/node/1276450

@MariskaTh
Sounds like you just need to alter your field order in the Line Items View (assuming that I'm following you correctly)

MariskaTh’s picture

@tzt20.

I took another look at it and now I see that the template generates the line items and order total separately. So when the payment method is the footer of the line items, it is displayed above the order total.

I tried to solve this by adding another footer 'Total order', just as the shopping cart summery view has. I placed this footer above the payment method footer. But somehow the Total order footer doesn't show. I don't know why.

I tried something else too. Here is a patch for the ability to use tokens in the invoice text field. https://www.drupal.org/node/2338751 I tried that. The payment method is on the right place now. But it says: Selected payment method: unknown

Any ideas?

Best regards,
Mariska.

MariskaTh’s picture

Status: Closed (fixed) » Active
MariskaTh’s picture

I figured it out.

When the payment method is in the footer of the view, then it is right below the line items, above the order total. However, I have placed it in the header and using CSS, you can give it a nice spot on the invoice.

Simple solution actually. :-)

Best regards,
Mariska.

MariskaTh’s picture

Status: Active » Closed (fixed)
Kirti_uplytics’s picture

Thank you, tzt20. I followed your steps, and it worked.!!! Very well explained!!