[Skip to main content](#vessel-content)

#   How to send PDF invoice together with mail button from the back-end?

##

- **[mark78](/forum/user/57441-mark78 "View mark78's Profile")**
- [![mark78's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/57441-mark78 "View mark78's Profile") Topic Author
- [ Offline](/forum/user/57441-mark78)

Less More

- Posts: 3
- Thank you received: 1
-
-

7 years 7 months ago -  7 years 7 months ago [\#305551](#305551) by [mark78](/forum/user/57441-mark78 "View mark78's Profile")  *[How to send PDF invoice with mail button from the back-end?](/forum/35-orders-management/897273-how-to-send-pdf-invoice-together-with-mail-button-from-the-back-end#305551 "Hi,  is there a way to alter the PDF invoice plugin so that the invoice will be sent when an order is created on the back-end? The plugin does work, but the pdf is only sent on 'confirmed' status. I offer web design services so I create the order for my customers and want to notify them with the email button (order&#95;notification.html.modified.php) and the invoice attached.  Setting the &quot;Statuses for email attachment&quot; in the plugin to &quot;Created&quot; did not work.  I also followed the instruction using the info on this post:   www.hikashop.com/forum/orders-management...s-and-invoicing.html , changing &quot;order&#95;confirmed&#95;status&quot; in line 345 of attachinvoice.php to &quot;invoice&#95;order&#95;statuses&quot;, but no luck so far. Did I overlook something? How to get this working? Thanks in advance, Mark")* was created by *[mark78](/forum/user/57441-mark78 "View mark78's Profile")*

Hi,

is there a way to alter the PDF invoice plugin so that the invoice will be sent when an order is created on the back-end? The plugin does work, but the pdf is only sent on 'confirmed' status.
I offer web design services so I create the order for my customers and want to notify them with the email button (order_notification.html.modified.php) and the invoice attached.

Setting the "Statuses for email attachment" in the plugin to "Created" did not work.

I also followed the instruction using the info on this post: [ www.hikashop.com/forum/orders-management...s-and-invoicing.html](https://www.hikashop.com/forum/orders-management/868485-order-statuses-and-invoicing.html),
changing "order_confirmed_status" in line 345 of attachinvoice.php to "invoice_order_statuses", but no luck so far. Did I overlook something? How to get this working? Thanks in advance,
Mark

Last edit: 7 years 7 months ago by [mark78](/forum/user/57441-mark78 "View mark78's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg5NzI3My1ob3ctdG8tc2VuZC1wZGYtaW52b2ljZS10b2dldGhlci13aXRoLW1haWwtYnV0dG9uLWZyb20tdGhlLWJhY2stZW5kP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86583
- Thank you received: 14324
-
-

7 years 7 months ago [\#305556](#305556) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to send PDF invoice together with mail button from the back-end?](/forum/35-orders-management/897273-how-to-send-pdf-invoice-together-with-mail-button-from-the-back-end#305556 "Hi,  is there a way to alter the PDF invoice plugin so that the invoice will be sent when an order is created on the back-end? The plugin does work, but the pdf is only sent on 'confirmed' status. I offer web design services so I create the order for my customers and want to notify them with the email button (order&#95;notification.html.modified.php) and the invoice attached.  Setting the &quot;Statuses for email attachment&quot; in the plugin to &quot;Created&quot; did not work.  I also followed the instruction using the info on this post:   www.hikashop.com/forum/orders-management...s-and-invoicing.html , changing &quot;order&#95;confirmed&#95;status&quot; in line 345 of attachinvoice.php to &quot;invoice&#95;order&#95;statuses&quot;, but no luck so far. Did I overlook something? How to get this working? Thanks in advance, Mark")*

Hi,

The "order notification" email is not supported by the PDF invoice plugin.
You would also have to change the line:
if(empty($data-&gt;mail_name) &#124;&#124; !in_array($data-&gt;mail_name, array('order_status_notification', 'order_creation_notification')))
to add 'order_notification' to the list of emails to handle.

The following user(s) said Thank You: [fernando.alh](/forum/user/29824-fernando-alh "View fernando.alh's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg5NzI3My1ob3ctdG8tc2VuZC1wZGYtaW52b2ljZS10b2dldGhlci13aXRoLW1haWwtYnV0dG9uLWZyb20tdGhlLWJhY2stZW5kP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mark78](/forum/user/57441-mark78 "View mark78's Profile")**
- [![mark78's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/57441-mark78 "View mark78's Profile") Topic Author
- [ Offline](/forum/user/57441-mark78)

Less More

- Posts: 3
- Thank you received: 1
-
-

7 years 7 months ago [\#305575](#305575) by [mark78](/forum/user/57441-mark78 "View mark78's Profile")  Replied by *[mark78](/forum/user/57441-mark78 "View mark78's Profile")* on topic *[How to send PDF invoice together with mail button from the back-end?](/forum/35-orders-management/897273-how-to-send-pdf-invoice-together-with-mail-button-from-the-back-end#305575 "Hi,  is there a way to alter the PDF invoice plugin so that the invoice will be sent when an order is created on the back-end? The plugin does work, but the pdf is only sent on 'confirmed' status. I offer web design services so I create the order for my customers and want to notify them with the email button (order&#95;notification.html.modified.php) and the invoice attached.  Setting the &quot;Statuses for email attachment&quot; in the plugin to &quot;Created&quot; did not work.  I also followed the instruction using the info on this post:   www.hikashop.com/forum/orders-management...s-and-invoicing.html , changing &quot;order&#95;confirmed&#95;status&quot; in line 345 of attachinvoice.php to &quot;invoice&#95;order&#95;statuses&quot;, but no luck so far. Did I overlook something? How to get this working? Thanks in advance, Mark")*

Thanks for your reply!

I can't get it working though, think I have tried most options. What I have done:

- installed the PDF invoice plugin once again
- Put the status "created" in the override setting in the plugin. I understand that this overrides variable $confirmed, is this correct?
- 'Override on the backend': Yes

In attachinvoice.php in the function onBeforeMailSend
- changed line 335 in : $confirmed = array($config-&gt;get('invoice_order_statuses', 'confirmed'));
(however, I don't know about this. Or is 'invoice_order_statuses' only for the 'pending' status? )

- changed line 341 in : if(empty($data-&gt;mail_name) &#124;&#124; !in_array($data-&gt;mail_name, array('order_notification', 'order_creation_notification'))) like you said.

What am I doing wrong? I tried to send an email and invoice attachment using the email button on the backend for every status, but I still get no pdf, only an email.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg5NzI3My1ob3ctdG8tc2VuZC1wZGYtaW52b2ljZS10b2dldGhlci13aXRoLW1haWwtYnV0dG9uLWZyb20tdGhlLWJhY2stZW5kP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86583
- Thank you received: 14324
-
-

7 years 7 months ago [\#305633](#305633) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to send PDF invoice together with mail button from the back-end?](/forum/35-orders-management/897273-how-to-send-pdf-invoice-together-with-mail-button-from-the-back-end#305633 "Hi,  is there a way to alter the PDF invoice plugin so that the invoice will be sent when an order is created on the back-end? The plugin does work, but the pdf is only sent on 'confirmed' status. I offer web design services so I create the order for my customers and want to notify them with the email button (order&#95;notification.html.modified.php) and the invoice attached.  Setting the &quot;Statuses for email attachment&quot; in the plugin to &quot;Created&quot; did not work.  I also followed the instruction using the info on this post:   www.hikashop.com/forum/orders-management...s-and-invoicing.html , changing &quot;order&#95;confirmed&#95;status&quot; in line 345 of attachinvoice.php to &quot;invoice&#95;order&#95;statuses&quot;, but no luck so far. Did I overlook something? How to get this working? Thanks in advance, Mark")*

Hi,

Yes, if you set created in the status override setting of the plugin, you don't need to change the line $confirmed = array($config-&gt;get('invoice_order_statuses', 'confirmed')); of the plugin as the override will be used.
And the other change looks good. So I don't see why it wouldn't work.
It should at least generate an error or something. That would require some debugging to see which condition prevents the plugin from adding the PDF.
In the plugin file, you have 4 conditions which can stop that process: Code:

// Valid order type if(!empty($data-&gt;data-&gt;order_type) &amp;&amp; $data-&gt;data-&gt;order_type != 'sale') return; // Valid email if(empty($data-&gt;mail_name) &#124;&#124; !in_array($data-&gt;mail_name, array('order_status_notification', 'order_creation_notification'))) return; // Valid status if(empty($data-&gt;data-&gt;order_status) &#124;&#124; !in_array($data-&gt;data-&gt;order_status, $confirmed)) return; // $invoice_id_required = $this-&gt;params-&gt;get('invoice_id_required', 0); if(empty($data-&gt;data-&gt;order_invoice_id) &amp;&amp; !empty($invoice_id_required)) return;

try removing the conditions one by one to see which one is blocking the process from adding the PDF.
Once you find the condition, that will help understand why it doesn't work.

The following user(s) said Thank You: [mark78](/forum/user/57441-mark78 "View mark78's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg5NzI3My1ob3ctdG8tc2VuZC1wZGYtaW52b2ljZS10b2dldGhlci13aXRoLW1haWwtYnV0dG9uLWZyb20tdGhlLWJhY2stZW5kP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mark78](/forum/user/57441-mark78 "View mark78's Profile")**
- [![mark78's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/57441-mark78 "View mark78's Profile") Topic Author
- [ Offline](/forum/user/57441-mark78)

Less More

- Posts: 3
- Thank you received: 1
-
-

7 years 7 months ago [\#305696](#305696) by [mark78](/forum/user/57441-mark78 "View mark78's Profile")  Replied by *[mark78](/forum/user/57441-mark78 "View mark78's Profile")* on topic *[How to send PDF invoice together with mail button from the back-end?](/forum/35-orders-management/897273-how-to-send-pdf-invoice-together-with-mail-button-from-the-back-end#305696 "Hi,  is there a way to alter the PDF invoice plugin so that the invoice will be sent when an order is created on the back-end? The plugin does work, but the pdf is only sent on 'confirmed' status. I offer web design services so I create the order for my customers and want to notify them with the email button (order&#95;notification.html.modified.php) and the invoice attached.  Setting the &quot;Statuses for email attachment&quot; in the plugin to &quot;Created&quot; did not work.  I also followed the instruction using the info on this post:   www.hikashop.com/forum/orders-management...s-and-invoicing.html , changing &quot;order&#95;confirmed&#95;status&quot; in line 345 of attachinvoice.php to &quot;invoice&#95;order&#95;statuses&quot;, but no luck so far. Did I overlook something? How to get this working? Thanks in advance, Mark")*

Fixed it!! Thanks a lot, Nicolas!

By removing this condition: Code:

// Valid status if(empty($data-&gt;data-&gt;order_status) &#124;&#124; !in_array($data-&gt;data-&gt;order_status, $confirmed)) return; //

the pdf showed up.

Then for some reason the order number was missing in the file name. Retrieved it by substituting line 461:
Code:

$invoice_name = JText::sprintf('PDF_INVOICE', $data-&gt;data-&gt;order_invoice_number);

for: Code:

$invoice_name = JText::_('INVOICE').'_'.$order-&gt;order_invoice_number;

The following user(s) said Thank You: [fernando.alh](/forum/user/29824-fernando-alh "View fernando.alh's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg5NzI3My1ob3ctdG8tc2VuZC1wZGYtaW52b2ljZS10b2dldGhlci13aXRoLW1haWwtYnV0dG9uLWZyb20tdGhlLWJhY2stZW5kP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.059 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
