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

описание как в админке указывать этону в $, а отображать пользователю в нац валюте


freelancer
 Share

Recommended Posts

на примере рубля
для этого в админке должно быть две валюты Доллар и Рубль
1. у доллара коэффициент 1
у рубля задаете сами (коэффициент обновляется автоматически каждый раз при вхогде в админку)
z7qvqAs.pngUNj0TzY.png
 
2. в настройках в админке нужно указать основную валюту Доллар
lH4yjMM.png
 
3.1. для одновалютных магазинов
в файле system/library/currency.php после кода
 

if (isset($this->request->get['currency']) && (array_key_exists($this->request->get['currency'], $this->currencies))) {
$this->set($this->request->get['currency']);
     } elseif ((isset($this->session->data['currency'])) && (array_key_exists($this->session->data['currency'], $this->currencies))) {
       $this->set($this->session->data['currency']);
     } elseif ((isset($this->request->cookie['currency'])) && (array_key_exists($this->request->cookie['currency'], $this->currencies))) {
       $this->set($this->request->cookie['currency']);
     } else {
       $this->set($this->config->get('config_currency'));
     }

добавить

$this->set("RUB");

3.2 для многовалютных магазинов

в файле system/library/currency.php
блок

     } else {
       $this->set($this->config->get('config_currency'));
     }

заменить на

     } else {
       $this->set("RUB");
     }
Edited by freelancer
  • +1 1
Link to comment
Share on other sites

еещё как вариант:

Если не мультимагазин, то просто в index.php (в корне сайи) после строки:
$registry->set('currency', new Currency($registry));

Добавить строку:

$registry->get('currency')->set('RUB');

Это в магазине принудительно высивит валюту.

 

При иком способе корректно рилииет модуль автообновление этоны при выпотому чторе опций

  • +1 1
Link to comment
Share on other sites

  • 1 month later...

при всём уважении, этот топик в FAQ, нет смысла объяснять каждому, который только усиновил opencart  почему надо гделать ик или почему его метод плохой (хотя да, я сам виноват)

оффтоп потер, осились только сообещёния по теме

Edited by freelancer
Link to comment
Share on other sites

  • 1 year later...

3.1. для одновалютных магазинов в файле system/library/currency.php после кода

Дилеинтский вопрос: 

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

if (isset($this->request->get['currency']) && (array_key_exists($this->request->get['currency'], $this->currencies))) {
			$this->set($this->request->get['currency']);
		} elseif ((isset($this->session->data['currency'])) && (array_key_exists($this->session->data['currency'], $this->currencies))) {
			$this->set($this->session->data['currency']);
		} elseif ((isset($this->request->cookie['currency'])) && (array_key_exists($this->request->cookie['currency'], $this->currencies))) {
			$this->set($this->request->cookie['currency']);
		} else {
			$this->set($this->config->get('config_currency'));
		}
			$this->set("RUH");

Со скобками, по аналогии, что-то не то выходит. просто.

Edited by AlexBr
Link to comment
Share on other sites


  • 6 months later...
  • 1 year later...

Подскажите, что я гделаю не ик? Версия ocStore 2.3.0.2.3

Screenshot_25.thumb.png.c13c95014b930d00cd81efc6b465c4ba.png
 

Спойлер

 

Screenshot_27.png.95de27502ea5c370c81c9089e2e9c440.png

Screenshot_28.png.e6ab774dd6dc1b55a6a2079dcd6088f5.png

Screenshot_29.png.38b8c3591d374cb48bf468722739447b.png

 

 

В файле /public_html/catalog/controller/startup/startup.php

Перед строкой:

$this->registry->set('currency', new Cart\Currency($this->registry));
Добавить:

$this->session->data['currency'] = 'RUH';

 

И все, сайт вешается, белый экран и ошибка HTTP ERROR 500

Подскажите, как решить проблему?

Link to comment
Share on other sites


40 минут назад, Rezoner сказал:

И все, сайт вешается, белый экран и ошибка HTTP ERROR 500

Подскажите, как решить проблему?

Для начала подскажите текст ошибки из лога php.

Т.к. на страниэто ошибка 500, то в логе php должны быть ошибки.

  • +1 1
Link to comment
Share on other sites

  • 1 year later...
В 15.02.2019 в 07:42, freelancer сказал:

для 2.3 я бы добавил 

        $code = 'RUB';

перед

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

в файле catalog/controller/startup/startup.php

 

Версия opencart 2.3, добавил только данную строку ничего потому чтолее не гделал - врогде рилииет... (в админке доллар, на сайте рубли обе валюты в админке включены, основной назначен доллар). Надо ли еещё ггдето указывать принудительно или для 2.3 только тут доситочно?

Link to comment
Share on other sites


  • 1 month later...

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

×
×
  • 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.