Answer the question
In order to leave comments, you need to log in
How to force language in Opencart?
Good afternoon. There is a multishop on subdomains (Opencart 2x) - a grid of regional sites.
Each store has its own language in the settings (for unique text descriptions).
The problem is that by default, when opening any subdomain, the default language of the main store is set, and the desired language has to be selected manually. The definition in the store settings does not play a role.
Question: how can I force the language to be written? (for example, in a template, since each subdomain uses its own, separate template, but the product base is common). That is: there is no need to select the desired localization language on the site, but it is necessary that it be fixed.
I am attaching the language switcher output code just in case
<?php if (count($languages) > 1) { ?>
<div class="pull-left">
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="language">
<div class="btn-group">
<button class="btn btn-link dropdown-toggle" data-toggle="dropdown">
<?php foreach ($languages as $language) { ?>
<?php if ($language['code'] == $code) { ?>
<img src="image/flags/<?php echo $language['image']; ?>" alt="<?php echo $language['name']; ?>" title="<?php echo $language['name']; ?>">
<?php } ?>
<?php } ?>
<span class="hidden-xs hidden-sm hidden-md"><?php echo $text_language; ?></span> <i class="fa fa-caret-down"></i></button>
<ul class="dropdown-menu">
<?php foreach ($languages as $language) { ?>
<li><a href="<?php echo $language['code']; ?>"><img src="image/flags/<?php echo $language['image']; ?>" alt="<?php echo $language['name']; ?>" title="<?php echo $language['name']; ?>" /> <?php echo $language['name']; ?></a></li>
<?php } ?>
</ul>
</div>
<input type="hidden" name="code" value="" />
<input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
</form>
</div>
<?php } ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question