Jump to content
Sign in to follow this  
nickolson

смена валюты с р. на RUB.

Recommended Posts

Добрый вечер!

Никогда не работал с опенкарт, но вот попросили очень срочно сделать одну фишку. По стандарту на сайте цена в

рублях - "р.", нужно при переключении на английскую версию выводить "RUB".

Подскажите пожалуйста, как это реализовать?

Share this post


Link to post
Share on other sites

Добрый вечер.

 

Можно сделать небольшой костыль.

В файле system/library/currency после кода:

	if ($currency && $this->has($currency)) {
      		$symbol_left   = $this->currencies[$currency]['symbol_left'];
      		$symbol_right  = $this->currencies[$currency]['symbol_right'];
      		$decimal_place = $this->currencies[$currency]['decimal_place'];
    	} else {
      		$symbol_left   = $this->currencies[$this->code]['symbol_left'];
      		$symbol_right  = $this->currencies[$this->code]['symbol_right'];
      		$decimal_place = $this->currencies[$this->code]['decimal_place'];
			
			$currency = $this->code;
    	}

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

    	$symbol_right = $this->language->get($this->code . '_symbol_right');

Потом в языковой файл catalog/language/russian/russian.php добавить:

$_['RUB_symbol_right']        = 'р.';

 

и в catalog/language/english/english.php

$_['RUB_symbol_right']        = 'RUB';

 

Для других валют, добавить соответственно.

Share this post


Link to post
Share on other sites

Более правильно заменить строку:

$symbol_right  = $this->currencies[$this->code]['symbol_right'];

На:

$symbol_right = $this->language->get($this->code . '_symbol_right');

Строку:

$symbol_right  = $this->currencies[$currency]['symbol_right'];

Заменить на:

$symbol_right = $this->language->get($currency . '_symbol_right');

Share this post


Link to post
Share on other sites

в итоге файл  system/library/currency должен быть:

if ($currency && $this->has($currency)) {
      		$symbol_left   = $this->currencies[$currency]['symbol_left'];
      		$symbol_right = $this->language->get($currency . '_symbol_right');
      		$decimal_place = $this->currencies[$currency]['decimal_place'];
    	} else {
      		$symbol_left   = $this->currencies[$this->code]['symbol_left'];
      		$symbol_right = $this->language->get($this->code . '_symbol_right');
      		$decimal_place = $this->currencies[$this->code]['decimal_place'];
			
			$currency = $this->code;
    	}

верно?

Share this post


Link to post
Share on other sites

в итоге файл  system/library/currency должен быть:

верно?

Это:

	if ($currency && $this->has($currency)) {
      		$symbol_left   = $this->currencies[$currency]['symbol_left'];
      		$symbol_right  = $this->currencies[$currency]['symbol_right'];
      		$decimal_place = $this->currencies[$currency]['decimal_place'];
    	} else {
      		$symbol_left   = $this->currencies[$this->code]['symbol_left'];
      		$symbol_right  = $this->currencies[$this->code]['symbol_right'];
      		$decimal_place = $this->currencies[$this->code]['decimal_place'];
			
			$currency = $this->code;
    	}

Заменить на это:

	if ($currency && $this->has($currency)) {
      		$symbol_left   = $this->currencies[$currency]['symbol_left'];
      		$symbol_right = $this->language->get($currency . '_symbol_right');
      		$decimal_place = $this->currencies[$currency]['decimal_place'];
    	} else {
      		$symbol_left   = $this->currencies[$this->code]['symbol_left'];
      		$symbol_right = $this->language->get($this->code . '_symbol_right');
      		$decimal_place = $this->currencies[$this->code]['decimal_place'];
			
			$currency = $this->code;
    	}

Share this post


Link to post
Share on other sites

Сделал как вы сказали, теперь и в русской и в анг.версии сайта я вижу вот такую цену:

500.00RUB_symbol_right

А хотелось бы в русской версии видеть - 500.00 р.

а в анг. 500.00 RUB.

Share this post


Link to post
Share on other sites

Вы не добавили строки в зыковые файлы.

 

В языковой файл catalog/language/russian/russian.php добавить:

$_['RUB_symbol_right']        = ' р.';

 

и в catalog/language/english/english.php

$_['RUB_symbol_right']        = ' RUB';

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

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.