Invoice Email PDF file name

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Webrocker
Posts: 6
Joined: 05 Dec 2023, 17:36

Invoice Email PDF file name

Post by Webrocker » 22 Jan 2024, 11:41

Hi,

is there an option to alter the filename of the PDF that gets attached to the order/payment email when the option "pdf = 1" is set ("invoice-123.pdf")?

thanks again,
Tom

Webrocker
Posts: 6
Joined: 05 Dec 2023, 17:36

Re: Invoice Email PDF file name

Post by Webrocker » 22 Jan 2024, 20:15

I found this:

https://github.com/aimeos/ai-controller ... 3C2-L303C1

Code: Select all

	protected function filename( \Aimeos\MShop\Order\Item\Iface $order ) : string
	{
		return $this->context()->translate( 'controller/jobs', 'Invoice' ) . '-' . $order->getInvoiceNumber() . '.pdf';
	}
since here the filename is hard coded, it doesn't look like it is supposed to be changed via config

User avatar
aimeos
Administrator
Posts: 8027
Joined: 01 Jan 1970, 00:00

Re: Invoice Email PDF file name

Post by aimeos » 23 Jan 2024, 08:00

Not via configuration but you can overwrite it in the ext_localconf.php of your own project-specific Aimeos extension like this:

Code: Select all

\Aimeos\Controller\Jobs\Order\Email\Payment\Standard::macro( 'filename', function( \Aimeos\MShop\Order\Item\Iface $order ) {
	return 'Bestellung-' . $order->getId() . '_' . $order->getTimeCreated() . '.pdf';
} );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Webrocker
Posts: 6
Joined: 05 Dec 2023, 17:36

Re: Invoice Email PDF file name

Post by Webrocker » 24 Jan 2024, 17:55

Code: Select all

\Aimeos\Controller\Jobs\Order\Email\Payment\Standard::macro( 'filename', function( \Aimeos\MShop\Order\Item\Iface $order ) {
	return 'Bestellung-' . $order->getId() . '_' . $order->getTimeCreated() . '.pdf';
} );
Can confirm this works fine! Thank you. :-)

Post Reply