News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

VirtueMart switches language when you place an order

Started by sandomatyas, March 31, 2017, 20:30:35 PM

Previous topic - Next topic

sandomatyas

I created a brand new simple Joomla 3.6.5 + VirtueMart 3.2.1 site.

  • added two languages to Joomla and Virtuemart too: English and Hungarian
  • created two categories (cars and phones) and two products in both languages
  • set Hungarian as default site language
  • added a language switcher mondule and a VirtueMart category module
  • opened the front page
  • switched to English
  • added a product to the cart
  • placed the order in English

The result screen is half-Hungarian and half-English: https://snag.gy/6CpzDR.jpg
The url is /en/virtuemart/cart so the language code is okay.
It looks like Joomla is still in English but VirtueMart switched back to Hungarian.

I debugged a bit and found function setLanguageByTag() in class vmLanguage
I put a logging code snippet there and found that the value of $siteLang is en-GB;en-GB;en-GB;en-GB;en-GB;en-GB;hu-HU
So something called this function with hu-HU
I think it's in the function notifyCustomer() in VirtueMartModelOrders class with this line:
shopFunctionsF::loadOrderLanguages($vLang);
because the value of $vLang is hu-HU in this scenario.

Could you check this please?


jjk

Might be easier to see if something is missing if you could provide a link to the shop.
From the screenshot it seems that you did not yet translate your Hungarian language categories into English. You will need menus in both languages and also a Joomla language switcher module for each language.

And when you do a test purchase, don't use your super administrator account to login. Instead create a test customer account.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

sandomatyas

Thanks, the site was on localhost but here you go, I uploaded it to a server: http://www.vmlang.tk/hu/
The login for the demo user is: demo/demodemo

jjk

I would suggest that you first add a few things which you didn't configure yet. You may use this link as an example: http://vm3test.schumacher-netz.de/j36vm32/index.php/en/

For example:
- I don't see a published category on your site yet. I noticed a published 'Latest products' module only.
- Also you should add menu links to the cart, order history, and customer account.
- Actually translate your products and publish the translations. Check into your database if your products in Hungarian language are stored in the product table xxxx_virtuemart_products_hu_hu and not in xxxx_virtuemart_products_en_gb.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

sandomatyas

Quote- I don't see a published category on your site yet. I noticed a published 'Latest products' module only.
I don't have 'latest products' but have 'VM-Category' module and all of my categories and products are translated https://snag.gy/S7v21Z.jpg

QuoteAlso you should add menu links to the cart, order history, and customer account.
I'm not sure how this is realted to the problem but okay, I created these menu items, placed an order with the same result.

QuoteActually translate your products and publish the translations. Check into your database if your products in Hungarian language are stored in the product table xxxx_virtuemart_products_hu_hu and not in xxxx_virtuemart_products_en_gb.
All of them are translated and stored well.

I've also recorded a screencast video with the problem: https://www.screencast.com/t/VkRcfI0E

jjk

I can't reproduce your issue. With my test installation as well as with my live shop it is working correctly.

The only 'unusual' thing I can see in your demo are these lines in the source code of the 'Thank you' page, which I don't have:

   <title>Köszönjük a megrendelését!</title>
   <link href="http://www.vmlang.tk/hu/cart" rel="alternate" hreflang="hu-HU" />
   <link href="http://www.vmlang.tk/en/cart" rel="alternate" hreflang="en-GB" />

Might be related to a Joomla configuration.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

sandomatyas

It's weird. Three of my sites have the same issue.
Should I send you a superuser login to check what I missed? I also asked Milbo (I have a support membership)

jjk

Works on my test installation. See screenshot.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

sandomatyas

Finally I found the problem/solution.
If you check notifyCustomer() function in VirtueMartModelOrders class you can see these lines:

$vu = JFactory::getUser($vendorUserId);
$vLang = $vu->getParam('admin_language',VmConfig::$jDefLangTag);
shopFunctionsF::loadOrderLanguages($vLang);

This sets the language to the vendor's/site backend's language to send vendor emails which is okay.
Later VM switches back to  the current language but only if sending the shopper email was successful!

In my test site email sending was disabled per server but VM changed the language for the vendor email (which was never sent) but didn't switched back.
On the production site there was a misconfiguration by the previous developer, so if you used English language you didn't received emails.
Maybe VM should switch back to the site language after sending/trying to send vendor email, regardless the shopper email.