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

#   Dateiname Rechnung PDF mit Kundenname

##

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

Less More

- Posts: 43
- Thank you received: 3
-

11 months 4 weeks ago [\#369503](#369503) by [metzlermedia](/forum/user/40637-metzlermedia "View metzlermedia's Profile")  *[Dateiname Rechnung PDF mit Kundenname](/forum/35-orders-management/909922-dateiname-rechnung-pdf-mit-kundenname#369503 "-- HikaShop version -- : 6.1.1 -- Joomla version -- : 5.4.0 -- PHP version -- : 8.4.12  Hallo,  Das neue Plugin enthält ja jetzt im Dateinamen auch die Bestellnummer. Jedoch wünscht mein Kunde, dass im Dateiname auch der Kundenname mit steht. Leider kenn ich mich mit PHP nicht so gut aus. Könnten Sie mir dazu bitte den Code ergänzend generieren?  $invoice&#95;name = JText::sprintf('PDF&#95;INVOICE', $data-&gt;data-&gt;order&#95;invoice&#95;number); if($invoice&#95;name == 'PDF&#95;INVOICE') $invoice&#95;name = JText::&#95;('INVOICE'); $mailer-&gt;addAttachment($invoiceFolder.DS.$invoiceFile,$invoice&#95;name.'.pdf');  Vielen Dank. Mit freundlichen Grüße Kristina")* was created by *[metzlermedia](/forum/user/40637-metzlermedia "View metzlermedia's Profile")*

-- HikaShop version -- : 6.1.1
-- Joomla version -- : 5.4.0
-- PHP version -- : 8.4.12

Hallo,

Das neue Plugin enthält ja jetzt im Dateinamen auch die Bestellnummer. Jedoch wünscht mein Kunde, dass im Dateiname auch der Kundenname mit steht. Leider kenn ich mich mit PHP nicht so gut aus. Könnten Sie mir dazu bitte den Code ergänzend generieren?

$invoice_name = JText::sprintf('PDF_INVOICE', $data-&gt;data-&gt;order_invoice_number);
if($invoice_name == 'PDF_INVOICE')
$invoice_name = JText::_('INVOICE');
$mailer-&gt;addAttachment($invoiceFolder.DS.$invoiceFile,$invoice_name.'.pdf');

Vielen Dank.
Mit freundlichen Grüße
Kristina

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50LzkwOTkyMi1kYXRlaW5hbWUtcmVjaG51bmctcGRmLW1pdC1rdW5kZW5uYW1lP3RtcGw9bWFya2Rvd24=) 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
-
-

11 months 4 weeks ago [\#369508](#369508) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Dateiname Rechnung PDF mit Kundenname](/forum/35-orders-management/909922-dateiname-rechnung-pdf-mit-kundenname#369508 "-- HikaShop version -- : 6.1.1 -- Joomla version -- : 5.4.0 -- PHP version -- : 8.4.12  Hallo,  Das neue Plugin enthält ja jetzt im Dateinamen auch die Bestellnummer. Jedoch wünscht mein Kunde, dass im Dateiname auch der Kundenname mit steht. Leider kenn ich mich mit PHP nicht so gut aus. Könnten Sie mir dazu bitte den Code ergänzend generieren?  $invoice&#95;name = JText::sprintf('PDF&#95;INVOICE', $data-&gt;data-&gt;order&#95;invoice&#95;number); if($invoice&#95;name == 'PDF&#95;INVOICE') $invoice&#95;name = JText::&#95;('INVOICE'); $mailer-&gt;addAttachment($invoiceFolder.DS.$invoiceFile,$invoice&#95;name.'.pdf');  Vielen Dank. Mit freundlichen Grüße Kristina")*

Hi,

You can do something like that: Code:

$invoice_name = JText::sprintf('PDF_INVOICE', $data-&gt;data-&gt;billing_address-&gt;address_firstname.' '.$data-&gt;data-&gt;billing_address-&gt;address_lastname); if($invoice_name == 'PDF_INVOICE') $invoice_name = JText::_('INVOICE'); $mailer-&gt;addAttachment($invoiceFolder.DS.$invoiceFile,$invoice_name.'.pdf');

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

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

Less More

- Posts: 43
- Thank you received: 3
-

11 months 4 weeks ago -  11 months 4 weeks ago [\#369514](#369514) by [metzlermedia](/forum/user/40637-metzlermedia "View metzlermedia's Profile")  Replied by *[metzlermedia](/forum/user/40637-metzlermedia "View metzlermedia's Profile")* on topic *[Dateiname Rechnung PDF mit Kundenname](/forum/35-orders-management/909922-dateiname-rechnung-pdf-mit-kundenname#369514 "-- HikaShop version -- : 6.1.1 -- Joomla version -- : 5.4.0 -- PHP version -- : 8.4.12  Hallo,  Das neue Plugin enthält ja jetzt im Dateinamen auch die Bestellnummer. Jedoch wünscht mein Kunde, dass im Dateiname auch der Kundenname mit steht. Leider kenn ich mich mit PHP nicht so gut aus. Könnten Sie mir dazu bitte den Code ergänzend generieren?  $invoice&#95;name = JText::sprintf('PDF&#95;INVOICE', $data-&gt;data-&gt;order&#95;invoice&#95;number); if($invoice&#95;name == 'PDF&#95;INVOICE') $invoice&#95;name = JText::&#95;('INVOICE'); $mailer-&gt;addAttachment($invoiceFolder.DS.$invoiceFile,$invoice&#95;name.'.pdf');  Vielen Dank. Mit freundlichen Grüße Kristina")*

Thanks.
Unfortunately, the code doesn't work. The filename doesn't change.
Can you please help me again?

Last edit: 11 months 4 weeks ago by [metzlermedia](/forum/user/40637-metzlermedia "View metzlermedia's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50LzkwOTkyMi1kYXRlaW5hbWUtcmVjaG51bmctcGRmLW1pdC1rdW5kZW5uYW1lP3RtcGw9bWFya2Rvd24=) 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
-
-

11 months 4 weeks ago [\#369517](#369517) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Dateiname Rechnung PDF mit Kundenname](/forum/35-orders-management/909922-dateiname-rechnung-pdf-mit-kundenname#369517 "-- HikaShop version -- : 6.1.1 -- Joomla version -- : 5.4.0 -- PHP version -- : 8.4.12  Hallo,  Das neue Plugin enthält ja jetzt im Dateinamen auch die Bestellnummer. Jedoch wünscht mein Kunde, dass im Dateiname auch der Kundenname mit steht. Leider kenn ich mich mit PHP nicht so gut aus. Könnten Sie mir dazu bitte den Code ergänzend generieren?  $invoice&#95;name = JText::sprintf('PDF&#95;INVOICE', $data-&gt;data-&gt;order&#95;invoice&#95;number); if($invoice&#95;name == 'PDF&#95;INVOICE') $invoice&#95;name = JText::&#95;('INVOICE'); $mailer-&gt;addAttachment($invoiceFolder.DS.$invoiceFile,$invoice&#95;name.'.pdf');  Vielen Dank. Mit freundlichen Grüße Kristina")*

Hi,

Well, the invoice file name is generated in 2 places in the code of the plugin.

The code you asked us about is the one used when the plugin generates the PDF invoice and adds it to the email sent to the customer.
However, there is another code: Code:

$fileName = JText::_('INVOICE'); if($this-&gt;shipping_invoice){ $fileName = JText::_('SHIPPING_INVOICE'); } if(count($orderIds) == 1){ if(empty( $order-&gt;order_invoice_number)) $order-&gt;order_invoice_number = $order-&gt;order_number; if($this-&gt;shipping_invoice){ $fileName = JText::sprintf('PDF_SHIPPING_INVOICE', $order-&gt;order_invoice_number); if($fileName == 'PDF_SHIPPING_INVOICE') $fileName = JText::_('SHIPPING_INVOICE').'_'.$order-&gt;order_invoice_number; }else{ $fileName = JText::sprintf('PDF_INVOICE', $order-&gt;order_invoice_number); if($fileName == 'PDF_INVOICE') $fileName = JText::_('INVOICE').'_'.$order-&gt;order_invoice_number; } } ob_clean(); $html2pdf-&gt;Output(str_replace('/','',$fileName).'.pdf','D');

which is used to generate the invoice file when you click on the buttons of the interface to retrieve the invoice file.

So, if you're testing the change by using the buttons, it's normal that you don't see any change.
You would have to also change that second piece of code in a similar manner if you want it to affect the buttons.

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

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

Less More

- Posts: 43
- Thank you received: 3
-

11 months 4 weeks ago -  11 months 4 weeks ago [\#369531](#369531) by [metzlermedia](/forum/user/40637-metzlermedia "View metzlermedia's Profile")  Replied by *[metzlermedia](/forum/user/40637-metzlermedia "View metzlermedia's Profile")* on topic *[Dateiname Rechnung PDF mit Kundenname](/forum/35-orders-management/909922-dateiname-rechnung-pdf-mit-kundenname#369531 "-- HikaShop version -- : 6.1.1 -- Joomla version -- : 5.4.0 -- PHP version -- : 8.4.12  Hallo,  Das neue Plugin enthält ja jetzt im Dateinamen auch die Bestellnummer. Jedoch wünscht mein Kunde, dass im Dateiname auch der Kundenname mit steht. Leider kenn ich mich mit PHP nicht so gut aus. Könnten Sie mir dazu bitte den Code ergänzend generieren?  $invoice&#95;name = JText::sprintf('PDF&#95;INVOICE', $data-&gt;data-&gt;order&#95;invoice&#95;number); if($invoice&#95;name == 'PDF&#95;INVOICE') $invoice&#95;name = JText::&#95;('INVOICE'); $mailer-&gt;addAttachment($invoiceFolder.DS.$invoiceFile,$invoice&#95;name.'.pdf');  Vielen Dank. Mit freundlichen Grüße Kristina")*

Thank you very mutch.
That was the problem.

The new Code is: Code:

$fileName = JText::_('INVOICE'); if($this-&gt;shipping_invoice){ $fileName = JText::_('SHIPPING_INVOICE'); } if(count($orderIds) == 1){ // Sicherstellen, dass die Rechnungsnummer (oder Bestellnummer) gesetzt ist if(empty( $order-&gt;order_invoice_number)) $order-&gt;order_invoice_number = $order-&gt;order_number; // Kunden-Nachnamen abrufen und NULL/Existenz prüfen $customerLastName = ''; if (isset($order-&gt;billing_address) &amp;&amp; !empty($order-&gt;billing_address-&gt;address_lastname)) { $customerLastName = $order-&gt;billing_address-&gt;address_lastname; } else { $customerLastName = JText::_('CUSTOMER'); // Fallback Name } // Nachnamen bereinigen: Alle problematischen Zeichen (Leerzeichen, Punkte, Schrägstriche) durch Unterstrich ersetzen $search_chars = array('/', ' ', '.', ','); $sanitizedCustomerName = str_replace($search_chars, '_', $customerLastName); // BASIS DES DATEINAMENS: KUNDENNACHNAME-RECHNUNGSNUMMER // Enthält den Bindestrich zwischen Name und Nummer. $dynamicPart = $sanitizedCustomerName . '-' . $order-&gt;order_invoice_number; if($this-&gt;shipping_invoice){ $fileName = JText::sprintf('PDF_SHIPPING_INVOICE', $dynamicPart); if($fileName == 'PDF_SHIPPING_INVOICE') // Fallback: BEZEICHNUNG_KUNDENNAME-RECHNUNGSNUMMER $fileName = JText::_('SHIPPING_INVOICE').'_'.$dynamicPart; } else{ $fileName = JText::sprintf('PDF_INVOICE', $dynamicPart); if($fileName == 'PDF_INVOICE') // Fallback: BEZEICHNUNG_KUNDENNAME-RECHNUNGSNUMMER $fileName = JText::_('INVOICE').'_'.$dynamicPart; } } ob_clean(); // FINALE BEREINIGUNG: NUR Schrägstriche entfernen. // Da wir alle Leerzeichen vorher in Unterstriche umgewandelt haben, ist das sicherer. $outputFileName = str_replace('/', '', $fileName); $html2pdf-&gt;Output($outputFileName.'.pdf','D');

Last edit: 11 months 4 weeks ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50LzkwOTkyMi1kYXRlaW5hbWUtcmVjaG51bmctcGRmLW1pdC1rdW5kZW5uYW1lP3RtcGw9bWFya2Rvd24=) 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.053 seconds

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