Post by Milki » Tue Aug 22, 2017 12:15 am

Is there an option to change store in php depending on some criteria and reload a whole page?

So for example when php detects the language is set as italian it changes the store from store1 to store2 ?

So a php code if language=italian change current store to store2 ?

Any idea?

Newbie

Posts

Joined
Sat Oct 01, 2016 2:12 am

Post by webcorvo » Wed Aug 23, 2017 9:24 pm

Yes is possible

Opencart Developer - For custom work and support contact @ webcorvo@gmail.com


User avatar
Active Member

Posts

Joined
Mon Mar 20, 2017 11:42 pm
Location - Lisbon, Portugal

Post by MrPhil » Thu Aug 24, 2017 9:04 pm

The browser's configured language is available somewhere in PHP (getenv('HTTP_ACCEPT_LANGUAGE'), I think). I know that osCommerce attempts to use it to select the store language to be used. However, many people apparently just leave their browser messages etc. in English, so it doesn't do much good. Once you have the language, you could check if you have a store for that language, and redirect to that store with PHP header("Location: ......");. Just be sure the code is before any output to the browser, or you'll get a "Headers already sent" error message.

User avatar
Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm

Post by webcorvo » Thu Aug 24, 2017 9:15 pm

Is more safe to get the language by IP address ;)

Opencart Developer - For custom work and support contact @ webcorvo@gmail.com


User avatar
Active Member

Posts

Joined
Mon Mar 20, 2017 11:42 pm
Location - Lisbon, Portugal

Post by MrPhil » Fri Aug 25, 2017 9:19 pm

webcorvo wrote:
Thu Aug 24, 2017 9:15 pm
Is more safe to get the language by IP address ;)
OK, the IP address is in Brussels, Belgium. Is the user speaking Dutch/Flemish or French/Walloon?

User avatar
Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm

Post by Milki » Sun Aug 27, 2017 2:31 am

Nice discussion, guys, but it seems that you did not understand my question.

Newbie

Posts

Joined
Sat Oct 01, 2016 2:12 am

Post by Milki » Sun Aug 27, 2017 2:34 am

Well, in fact, it is my fault, I did not express myself sufficiently. I mean when an user change his or her language in the opencart store, then also a store (with its subdomain) is changed based on the language this user has chosen.

Newbie

Posts

Joined
Sat Oct 01, 2016 2:12 am

Post by thekrotek » Sun Aug 27, 2017 3:38 am

Milki wrote:
Sun Aug 27, 2017 2:34 am
Well, in fact, it is my fault, I did not express myself sufficiently. I mean when an user change his or her language in the opencart store, then also a store (with its subdomain) is changed based on the language this user has chosen.
And why exactly do you want this? I can't seem to imagine any decent reason myself.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am

Who is online

Users browsing this forum: No registered users and 270 guests