Opencart 1.5.1: возможность регулировать точность и количество десятичных знаков при выводе веса и размеров
Добавлена возможность настройки точности чисел при выводе веса и размеров (количество знаков после зяпятой). Регулируется парой цифр в языковых файлах - там же, где и десятичные разделители и разделители тысяч (точка, запятая, пробел, апостроф и т.п. - кому что нравится).
commit b8607fb31b2d9c414506c513b8fb4b8593cbc214
Author: Ruslan Brest <rb@labtodo.com>
Date: Sun Dec 4 14:12:47 2011 +0200
[+] Возможность настройки точности чисел при выводе веса и размеров (количество знаков после зяпятой)
diff --git a/public_html/admin/language/english/english.php b/public_html/admin/language/english/english.php
index 5a0223c..71bb46d 100644
--- a/public_html/admin/language/english/english.php
+++ b/public_html/admin/language/english/english.php
@@ -7,6 +7,8 @@ $_['date_format_long'] = 'l dS F Y';
$_['time_format'] = 'h:i:s A';
$_['decimal_point'] = '.';
$_['thousand_point'] = ',';
+$_['length_decimals'] = 2;
+$_['weight_decimals'] = 2;
// Text
$_['text_yes'] = 'Yes';
diff --git a/public_html/admin/language/russian/russian.php b/public_html/admin/language/russian/russian.php
index d68a762..2cdbc95 100644
--- a/public_html/admin/language/russian/russian.php
+++ b/public_html/admin/language/russian/russian.php
@@ -7,6 +7,8 @@ $_['date_format_long'] = 'l, d F Y';
$_['time_format'] = 'H:i:s';
$_['decimal_point'] = '.';
$_['thousand_point'] = ',';
+$_['length_decimals'] = 0;
+$_['weight_decimals'] = 0;
// Text
$_['text_yes'] = 'Да';
diff --git a/public_html/catalog/language/english/english.php b/public_html/catalog/language/english/english.php
index cdf17cf..524e1d9 100644
--- a/public_html/catalog/language/english/english.php
+++ b/public_html/catalog/language/english/english.php
@@ -7,6 +7,8 @@ $_['date_format_long'] = 'l dS F Y';
$_['time_format'] = 'h:i:s A';
$_['decimal_point'] = '.';
$_['thousand_point'] = ',';
+$_['length_decimals'] = 2;
+$_['weight_decimals'] = 2;
// Text
$_['text_home'] = 'Home';
diff --git a/public_html/catalog/language/russian/russian.php b/public_html/catalog/language/russian/russian.php
index 48829a5..f69f200 100644
--- a/public_html/catalog/language/russian/russian.php
+++ b/public_html/catalog/language/russian/russian.php
@@ -7,6 +7,8 @@ $_['date_format_long'] = 'l d F Y';
$_['time_format'] = 'H:i:s';
$_['decimal_point'] = '.';
$_['thousand_point'] = '';
+$_['length_decimals'] = 0;
+$_['weight_decimals'] = 0;
// Text
$_['text_home'] = 'Главная';
diff --git a/public_html/system/library/length.php b/public_html/system/library/length.php
index 03ca441..3d02025 100644
--- a/public_html/system/library/length.php
+++ b/public_html/system/library/length.php
@@ -5,6 +5,7 @@ final class Length {
public function __construct($registry) {
$this->db = $registry->get('db');
$this->config = $registry->get('config');
+ $this->language = $registry->get('language');
$length_class_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "length_class mc LEFT JOIN " . DB_PREFIX . "length_class_description mcd ON (mc.length_class_id = mcd.length_class_id) WHERE mcd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
@@ -41,9 +42,9 @@ final class Length {
public function format($value, $length_class_id, $decimal_point = '.', $thousand_point = ',') {
if( 0 == $value ) return "";
if (isset($this->lengths[$length_class_id])) {
- return number_format($value, 2, $decimal_point, $thousand_point) . $this->lengths[$length_class_id]['unit'];
+ return number_format($value, $this->language->get('length_decimals'), $decimal_point, $thousand_point) . $this->lengths[$length_class_id]['unit'];
} else {
- return number_format($value, 2, $decimal_point, $thousand_point);
+ return number_format($value, $this->language->get('length_decimals'), $decimal_point, $thousand_point);
}
}
}
diff --git a/public_html/system/library/weight.php b/public_html/system/library/weight.php
index d55fdf9..cda9d4d 100644
--- a/public_html/system/library/weight.php
+++ b/public_html/system/library/weight.php
@@ -5,6 +5,7 @@ final class Weight {
public function __construct($registry) {
$this->db = $registry->get('db');
$this->config = $registry->get('config');
+ $this->language = $registry->get('language');
$weight_class_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "weight_class wc LEFT JOIN " . DB_PREFIX . "weight_class_description wcd ON (wc.weight_class_id = wcd.weight_class_id) WHERE wcd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
@@ -36,9 +37,9 @@ final class Weight {
public function format($value, $weight_class_id, $decimal_point = '.', $thousand_point = ',') {
if( 0 == $value ) return "";
if (isset($this->weights[$weight_class_id])) {
- return number_format($value, 2, $decimal_point, $thousand_point) . $this->weights[$weight_class_id]['unit'];
+ return number_format($value, $this->language->get('weight_decimals'), $decimal_point, $thousand_point) . $this->weights[$weight_class_id]['unit'];
} else {
- return number_format($value, 2, $decimal_point, $thousand_point);
+ return number_format($value, $this->language->get('weight_decimals'), $decimal_point, $thousand_point);
}
}
}
Еще записи по теме
- Русский перевод Opencart v1.5.0.5 (только магазин), v1.5.1.{1,2,3},1.5.2 (полный). Информация о других переводах (русский, украинский язык)
- Opencart module extract (Linux shell script)
- Opencart 1.5.x (catalog): как вывести третий уровень категорий в главном меню
- Вывод Git branch в подсказку командной строки
- Opencart 1.5.x -- 1.5.1.2 (admin): редактирование заказов
- Изменяем длину описаний товаров в каталоге OpenCart 1.5.x
- Убираем ограничение 999.99 на вес и размеры в Opencart




Оставьте комментарий!