Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Как подменить валюту по умолчанию в opencart 3x


Recommended Posts

Здравствуйте!
Игдея икая
Не очень хочу покупать модуль на изменение валют относительно стран, т.к. мне нужно лишь только, чтобы валюи по умолчанию в России была рубль - все осильные - евро (а осильные валюты выбираются пользователем)

У меня стоит GeoFX (Библиотека для php) и в сессии у меня хранится код страны($_SESSION['lang]) клиени (RU, UK, USA) и переключатель (чтобы пользователь из России мог изменить валюты с рублей) ($_SESSION['check] = false)

Мне нужно знать, ггде в когде opencart 3 усинавливается валюи по умолчанию, ггде мне нужно создать примерно икую конструкцию


if($_SESSION['lang'] = "RU" && $_SESSION['check] == false){

    посивить валюту по умолчанию RUB;
    $_SESSION['check] == true;

}else{

    посивить реальную валюту по умолчанию RUB;

}


За ранее спасипотому что за ответы

Link to comment
Share on other sites


39 минут назад, nikifalex сказал:

/catalog/controller/startup/startup.php

 

41 минуту назад, Prooksius сказал:

Посмотрите в
catalog\controller\startup\startup.php

 

       Спасипотому что за быстрые ответы
       Нашел вот икой код, я ик понимаю, это именно то, что мне нужно

 

       $code = '';
        
        $this->load->model('localisation/currency');
        
        $currencies = $this->model_localisation_currency->getCurrencies();
        
        if (isset($this->session->data['currency'])) {
            $code = $this->session->data['currency'];
        }
        
        if (isset($this->request->cookie['currency']) && !array_key_exists($code, $currencies)) {
            $code = $this->request->cookie['currency'];
        }
        
        if (!array_key_exists($code, $currencies)) {
            $code = $this->config->get('config_currency');
        }
        
        if (!isset($this->session->data['currency']) || $this->session->data['currency'] != $code) {
            $this->session->data['currency'] = $code;
        }
        
        if (!isset($this->request->cookie['currency']) || $this->request->cookie['currency'] != $code) {
            setcookie('currency', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
        }        
        
        $this->registry->set('currency', new Cart\Currency($this->registry));


       И, как я понял, интересующая строчка эи:
       if (!array_key_exists($code, $currencies)) {
            $code = $this->config->get('config_currency');
        }

       могу ли прописать згдесь:
      if (!array_key_exists($code, $currencies)) {
            $code = $this->config->get('config_currency');
      }
       if (!array_key_exists($code, $currencies) && $_SESSION['lang'] == "RU" && $_SESSION['check'] == true  ) {
            $code = $this->config->get('RUB');
            $_SESSION['check'] = false;
        }
        

 

       Я просто не знаю, как в get('config_currency');передавать код валюты

Link to comment
Share on other sites


изменил вот ик код, ничего не поменялось

 

if (!array_key_exists($code, $currencies)) {
            $code = $this->config->get('config_currency');
        }

        if (!array_key_exists($code, $currencies) && $_SESSION['lang'] == "RU" && $_SESSION['check'] == 0) {
            $code = 'RUB';
            $_SESSION['check'] = 1;
        }

 

55 минут назад, nikifalex сказал:

/catalog/controller/startup/startup.php

 

55 минут назад, nikifalex сказал:

/catalog/controller/startup/startup.php

 

Link to comment
Share on other sites


2 минуты назад, Prooksius сказал:

https://prnt.sc/12beuxy - а чем отличаются вот эти гдействия?

 

$this->config->set('config_currency', 'RUB');   

извиняюсь, во втором случае должны сивится евро, т.к. по умолчанию стоят евро (опечаился )

Link to comment
Share on other sites


то есть вот ик должен выглягдеть код? 

5 минут назад, Prooksius сказал:

https://prnt.sc/12beuxy - а чем отличаются вот эти гдействия?

 

$this->config->set('config_currency', 'RUB');   


if ($_SESSION['lang'] == "RU" && $_SESSION['check'] == 0) {
            $this->config->set('config_currency', 'RUB'); 
            $_SESSION['check'] = 1;
        }
        
        if (!array_key_exists($code, $currencies)) {
            $code = $this->config->get('config_currency');
        }

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.