When the invoice is generated originally, the content of the pdf matches the order language.
When the invoice is resent from the order administration, the current language is used to generate the PDF instead of the order preferred language.

CommentFileSizeAuthor
#5 28-08-_2014_11-35-55.jpg231.11 KBfugazi

Comments

anybody’s picture

Thanks a lot! I will check and try to fix that! :)
Currently the resend link is more a bonus function.

anybody’s picture

Priority: Normal » Minor

I'm not sure how to solve it. I'm afraid of changing the global $language before rendering the pdf.
Any ideas how to solve it properly?

anybody’s picture

Status: Active » Postponed (maintainer needs more info)
cjoy’s picture

Assigned: Unassigned » cjoy
fugazi’s picture

StatusFileSize
new231.11 KB

I tried it with Execute custom PHP code

$account = user_load($commerce_order->uid);
$languages = language_list();
global $language;
if ($language->language != $account->language) {
  $language = $languages[$account->language];
}

without success

anybody’s picture

I still have no idea how to solve this cleanly, so please help me if this is important for you.

fugazi’s picture

I would like to do if I could program well. I will look. Thank you for the answer.

stevieb’s picture

if the pdf is sent when a user manually updates the order to completed (used when the invoice is sent as the goods leave the storage)
and not when the checkout is completed the email and pdf gets sent in the admin language not the user order language.

I've tried to fix it with rules but am having no success :-(

anybody’s picture

Status: Postponed (maintainer needs more info) » Fixed

This is now fixed in the latest .dev release. Please test and review.

  • Anybody committed 1520ed7 on 7.x-1.x
    Issue [#2183633] by [cjoy,Anybody]: Resend Invoice: order language...

  • Anybody committed 4c2f7fe on 7.x-1.x
    Issue [#2183633] by [cjoy,Anybody]: The global $language variable was...
fugazi’s picture

I tested it and it works with limitations. All mails come in the language of the client, as it should. Wonderful thank you.

Saving the attached pdf bill comes in the set language of the admin. Only if they will send emial with notes about "resend invoice now" sent in the language of the customer.

I do not why that is happening.

anybody’s picture

@fugazi: Thanks a lot for your comment.
This is not part of this module I think but part of commerce_billy_pdf.

Here's the reason (commerce_billy_pdf.module):

function commerce_billy_pdf_html($order) {
  $vars['viewed_orders'][] = entity_view('commerce_order', array($order->order_id => $order), 'pdf', NULL, TRUE);
  // Add a credit memo.
  if ($order->status == 'canceled') {
    $vars['viewed_orders'][] = entity_view('commerce_order', array($order->order_id => $order), 'canceled', NULL, TRUE);
  }
  $css_files = variable_get('commerce_billy_pdf_css_files', array(drupal_get_path('module', 'commerce_billy_pdf') . '/css/pdf.css'));
  $vars['inline_css'] = "";
  foreach ($css_files as $file) {
    $vars['inline_css'] .= file_get_contents($file);
  }

  return theme('commerce_billy_pdf_page', $vars);
}

entity_view does not provide the user preferred language parameter in the entity_view() function.

It should also use the following snippet to determine the order users prefered language and pass it to entity_view():

$order_account_uid = $order->uid;
  $order_account = user_load($order_account_uid);
  // Get the order owners language.
  $order_account_language = user_preferred_language($order_account);

Please feel free to create a separate issue in commerce_billy_pdf project with reference to this comment.

Thanks a lot.

fugazi’s picture

Many many thanks, unfortunately I do not know where I can insert the snippet. I will continue to write on commerce_billy_pdf, perhaps one finds the way.

separate issue in commerce_billy_pdf project

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.