VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: mailblade on November 14, 2017, 10:12:21 AM

Title: Invoice name change issue.
Post by: mailblade on November 14, 2017, 10:12:21 AM
Latest VM ; Joomla 3.6

Hello.

I'm having some trouble with changing the invoice name which the user receives attached to the email which is sent to them.

I found these 2 lines in "mytemplate\components\com_virtuemart\controllers\invoice.php":


//$path .= preg_replace('/[^A-Za-z0-9_\-\.]/', '_', 'vm'.$layout.'_'.$invoiceNumber.'.pdf');
$path .= shopFunctionsF::getInvoiceName($invoiceNumber, $layout).'.pdf';


If I enable the top line and comment out the bottom one, the user is not able to download the PDF anymore from the "Order Details" page. They can only print it. They still receive it in the email though.

Now, currently the name of the invoice is: "vminvoice_invoicenumber.pdf" (invoiceumber is the automatically generated random letters)

Example: "vminvoice_171114185H0115"

How do I change the name of "$layout"?

I've been struggling a lot with this.

I've found no way to do this. If I use this:

$path .= preg_replace('/[^A-Za-z0-9_\-\.]/', '_',.$layout.'_'.$invoiceNumber.'.pdf');

it changes the name to just "invoice_171114185H0115". However the PDF is not able to be downloaded anymore, even though the user receives it in their mail.

I would like the download option to still be available if they want to download it at another time.




Title: Re: Invoice name change issue.
Post by: AH on November 14, 2017, 11:11:37 AM
What are you trying to change the name to ??


You are trying to change a function that requires the variables $invoiceNumber and $layout

You should continue to use this function:-

$path .= shopFunctionsF::getInvoiceName($invoiceNumber, $layout).'.pdf';


The creation of an invoice name is done in shopFunctionsF


Title: Re: Invoice name change issue.
Post by: mailblade on November 14, 2017, 13:09:53 PM
Thanks for the reply AH.

I'm trying to change the name to: "IKEA_ORDER_" and then the random invoice number after it.

I'll have a look in shopfunctions.

Yes I want to use the one you said I should.
Title: Re: Invoice name change issue.
Post by: AH on November 14, 2017, 14:45:45 PM
The invoice prefix is adjustable

You can just use a name language override.

COM_VIRTUEMART_FILEPREFIX_INVOICE="invoice_"