Post by ilian359 » Wed Nov 24, 2021 5:28 am

I am using Auto Invoice Number extension and I already have invoice number shown on checkout/success page. I would like to add it also to catalog/view/theme/default/template/mail/order_add.twig
This is important for me, because our local laws require invoice number to be present at bank transfer details as a payment reason. Please help me in passing invoice_no value to order_add.twig .

Image Image
Laptop repair specialist in Sofia, Bulgaria.
Maintaining own OC 3 shop for laptop screens


Newbie

Posts

Joined
Tue Aug 11, 2020 4:37 am

Post by by mona » Wed Nov 24, 2021 5:03 pm

Hi Lilian359,

Would you please be so kind as to read the forum rules before posting viewtopic.php?f=176&t=200480. In particular please always post your OC version using all four digits. You can find this at the bottom of every admin page.

This is out of the scope of free support you can find there is a commercial section where many people will respond to quote. Have you checked with the extension developer?

Even if we were to want to help, it would depend on where and when that extension generates and stores the invoice number.
The email is send just before the order history is written by the payment method(s) controller which is just before the success page is shown.

If the invoice number is generated and stored before the sending of the email (when the order is stored for instance) you can do this:

in catalog/controller/mail/order.php

you can add:

Code: Select all

$data['invoice_no'] = $order_info['invoice_no'];
before:

Code: Select all

$data['order_id'] = $order_info['order_id'];
in catalog/view/theme/default/mail/order_add.twig

add:

Code: Select all

{{ invoice_no }}
where you want it to appear.

if the invoice number is generated and stored after the email is send, then no such luck.

You can find the commercial section here : viewforum.php?f=88

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

User avatar
New member

Posts

Joined
Wed Aug 15, 2018 6:58 am
Location - Yogyakarta

Post by ilian359 » Sat Nov 27, 2021 4:27 am

Thank you, by mona!
I am sorry for forgetting about the exact version - it is 3.0.3.2.
Your proposed solution outputs "0" as an invoice number. Obviously it is generated later, and I am not familiar with consequence of procedures in Opencart. At least now I know that /catalog/controller/mail/order.php loads data to add_order.twig . It is a good point to start :)

P.S.: I have just added:

Code: Select all

$data['invoice_no'] = $this->model_checkout_order->createInvoiceNo($order_info['order_id']);

where you proposed. The function "createInvoiceNo" is a part of "Auto Invoice Number" extension and now it generates the number at mail/order.php . Thank you again, by mona! You gave me the clue that I've been searching for.

Image Image
Laptop repair specialist in Sofia, Bulgaria.
Maintaining own OC 3 shop for laptop screens


Newbie

Posts

Joined
Tue Aug 11, 2020 4:37 am

Post by straightlight » Sat Nov 27, 2021 7:25 am

ilian359 wrote:
Sat Nov 27, 2021 4:27 am
Thank you, by mona!
I am sorry for forgetting about the exact version - it is 3.0.3.2.
Your proposed solution outputs "0" as an invoice number. Obviously it is generated later, and I am not familiar with consequence of procedures in Opencart. At least now I know that /catalog/controller/mail/order.php loads data to add_order.twig . It is a good point to start :)

P.S.: I have just added:

Code: Select all

$data['invoice_no'] = $this->model_checkout_order->createInvoiceNo($order_info['order_id']);

where you proposed. The function "createInvoiceNo" is a part of "Auto Invoice Number" extension and now it generates the number at mail/order.php . Thank you again, by mona! You gave me the clue that I've been searching for.
By using an Event, this could be accomplished: https://github.com/opencart/opencart/wiki/Events-System

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: jagall, moreduff, Semrush [Bot] and 260 guests