PDF attachment plugin uses wrong language file

  • Posts: 154
  • Thank you received: 4
10 years 9 months ago #167001

-- HikaShop version -- : 2.3.2
-- Joomla version -- : 3.3.0

dear team,
i purchased and installed the pdf attachment plugin, all works fine, but, all text in PDF created and attached to the mail is in EN, even though the whole page is in DE and all mails created etc. are displayed in DE. is there an option to switch or set the PDF attachment plugin to DE? am i missing something?
best regards and thanks in advance!

Please Log in or Create an account to join the conversation.

  • Posts: 83806
  • Thank you received: 13571
  • MODERATOR
10 years 9 months ago #167301

Hi,

It's probably because you're using a payment gateway which notifies the website with a server to server connection and it doesn't specify any language for that notification. Because of that the current language is the main language of the website instead of the language of the user that the email system of HikaShop is able to handle.

Try to replace the code:

$order = $class->loadFullOrder($orderId,true,false);
			$fields['order'] = $fieldsClass->getFields('backend',$order,'order');
			ob_start();
			if(file_exists(HIKASHOP_MEDIA.'plugins'.DS.'invoice.php')){
				$file = HIKASHOP_MEDIA.'plugins'.DS.'invoice.php';
			}else{
				$file = dirname(__FILE__).DS.'attachinvoice'.DS.'invoice.php';
			}
			require($file);
			$pdfContent[] = ob_get_clean();
with:
$order = $class->loadFullOrder($orderId,true,false);
			$class->loadLocale($order);
			$fields['order'] = $fieldsClass->getFields('backend',$order,'order');
			ob_start();
			if(file_exists(HIKASHOP_MEDIA.'plugins'.DS.'invoice.php')){
				$file = HIKASHOP_MEDIA.'plugins'.DS.'invoice.php';
			}else{
				$file = dirname(__FILE__).DS.'attachinvoice'.DS.'invoice.php';
			}
			require($file);
			$pdfContent[] = ob_get_clean();
			if(method_exists($class,'loadBackLocale')){
				$class->loadBackLocale();
			}else{
				if($app->isAdmin()) {
					$config = JFactory::getConfig();
					if(!empty($class->oldLocale)){
						$config->set('language',$class->oldLocale);
						$debug = $config->get('debug');
						if(HIKASHOP_J25) JFactory::$language = new hikaLanguage($class->oldLocale, $debug);
					}
					$lang = JFactory::getLanguage();
					$override_path = JLanguage::getLanguagePath(JPATH_ROOT).DS.'overrides'.$lang->getTag().'.override.ini';
					if(version_compare(JVERSION,'1.6','>=')&& file_exists($override_path)) {
						$lang->override = $lang->parse($override_path);
					}
					$lang->load(HIKASHOP_COMPONENT, JPATH_SITE, null, true );
					if(version_compare(JVERSION,'1.6','<') && file_exists($override_path)) {
						$lang->_load($override_path,'override');
					}elseif(HIKASHOP_J25){
						$lang->publicLoadLanguage($override_path,'override');
					}
				}
			}
in the file plugins/hikashop/attachinvoice/attachinvoice.php so that it switch the language automatically based on the language of the user of the order for the display of the invoice.

The following user(s) said Thank You: olivnewton

Please Log in or Create an account to join the conversation.

  • Posts: 154
  • Thank you received: 4
10 years 9 months ago #167389

great! works like a charm!
thanks.
do i need to keep track of this change, or will it be part of the next possible pdf-attachment-plugin update?
also,
it is usually common to show the invoice number also in the filename, so i changed in the same file:
$mailer->addAttachment($invoiceFolder.DS.$invoiceFile,JText::_('INVOICE').'.pdf');
to
$mailer->addAttachment($invoiceFolder.DS.$invoiceFile,JText::_('INVOICE').'_'.$data->data->order_invoice_number.'.pdf');

could this also be incorporated into the next update or do you think there is no need for this?

Please Log in or Create an account to join the conversation.

  • Posts: 26233
  • Thank you received: 4036
  • MODERATOR
10 years 9 months ago #167405

Hi,

The Nicola's patch will be integrated into the invoice PDF plugin.
About your feature request, it's a good idea but I think that we will use a specific translation like

$invoice_name = JText::sprintf('PDF_INVOICE', $data->data->order_invoice_number);
if($invoice_name == 'PDF_INVOICE')
   $invoice_name = JText::_('INVOICE');
$mailer->addAttachment($invoiceFolder.DS.$invoiceFile,$invoice_name.'.pdf');
So it will allow to be more customizable.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Last edit: 10 years 9 months ago by Jerome.

Please Log in or Create an account to join the conversation.

  • Posts: 154
  • Thank you received: 4
10 years 9 months ago #167841

great! sounds good. thanks a lot

Please Log in or Create an account to join the conversation.

  • Posts: 154
  • Thank you received: 4
10 years 7 months ago #175848

now i noticed the same problem with "HikaShop bank transfer payment plugin"...
while paypal is working after the fix, bank transfer plugin still shows the invoice.pdf in the wring language...
any idea?

PS: FYI: only the attached invoice has the wring language, if i create the invoice in the backend its ok...

Last edit: 10 years 7 months ago by olivnewton.

Please Log in or Create an account to join the conversation.

  • Posts: 83806
  • Thank you received: 13571
  • MODERATOR
10 years 7 months ago #175889

Hi,

I don't see why the payment method selection would change anything for the language of the invoice since the patch I gave forces the system to reload the language of the user of the order before generating the PDF.
Are you sure that it's not because the user account you used had the language of the invoice set in it ?

Please Log in or Create an account to join the conversation.

  • Posts: 154
  • Thank you received: 4
10 years 7 months ago #175944

i just made some tests in order to understand this behaviour better and found out that:

if the user in the backend, who sets the order manually to "confirmed" uses as backend language EN then the PDF-invoice generated will use the EN language file, thus being in english...

if the user uses german, then invoice is correct.

shouldnt this rather be different? for example, no matter what a backend language the user dealing with the shop and orders has, the pdf invoice shuold be generated with the default language of the site. does that make sense?

Please Log in or Create an account to join the conversation.

  • Posts: 26233
  • Thank you received: 4036
  • MODERATOR
10 years 7 months ago #176079

Hi,

The HIkaShop emails are loading the user language in order to send the notification emails with the user language and not the backend logged user one.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 154
  • Thank you received: 4
10 years 6 months ago #176197

hi, i forgot to point out that we are using guest login, so there is not really a real user in the frontend...
what language does the system use in this case?

i repeat for the sake of being complete on this post:
- if the user in the backend, who sets the order manually to "confirmed" uses as backend language EN then the PDF-invoice generated will use the EN language file, thus being in english...
- if the user uses german, then invoice is correct.
- this happens only with "HikaShop bank transfer payment plugin", not with paypal

Please Log in or Create an account to join the conversation.

  • Posts: 83806
  • Thank you received: 13571
  • MODERATOR
10 years 6 months ago #177355

Hi,

If the user uses the guest checkout, the language information cannot be stored in the user data of the Joomla user account.
So in that case, the system doesn't know the language of the user and simply use the current language.
For PayPal, the system will use the language of the frontend and when we send the user to PayPal we give it the notification url with the current language so the language will correspond to the language of the user. So even even if we don't know the language of the user when the user guest checkout, the current language is the correct one during the payment notification and thus the user gets the PDF in the correct language.
For the bank transfer, there is no such information in the order and since you confirm the order manually from the backend, it just uses the language you're using.
I don't really have a solution here as the information is not stored and there is no place to store it at the moment so it would require substantial modifications to be able to handle that.

Please Log in or Create an account to join the conversation.

  • Posts: 154
  • Thank you received: 4
10 years 6 months ago #177360

i see...
so the joomla user handling all orders in the backend and setting the bank transfer orders manually to "confirmed" HAS to have setup GERMAN in order for the plugin to create the PDF invoice in german, right?

Please Log in or Create an account to join the conversation.

  • Posts: 83806
  • Thank you received: 13571
  • MODERATOR
10 years 6 months ago #177365

That's indeed the case.

Please Log in or Create an account to join the conversation.

Time to create page: 0.052 seconds
Powered by Kunena Forum