Thẩm mỹ viện Uy Tín | Web Chăm sóc Gia Đình

Tiêu đề: Hướng dẫn phân cách giá tiền cho ecshop [In trang]

Tác giả: admin    Thời gian: 18-11-2016 08:32
Tiêu đề: Hướng dẫn phân cách giá tiền cho ecshop
Bước 1:
- Truy cập vào Admin - Hệ thống - Cài đặt - (Tab) Hiển thị --> dòng Định dạng tiền tệ --> sửa đổi thành:
%s VNĐ
- Admin - Hệ thống - Cài đặt - (Tab) Hiển thị -->  Định dạng giá tiền --> Mặc định.

Bước 2: Mở file /include/lib_common.php
Tìm đoạn code:
  1. function price_format($price, $change_price = true)
  2. {
  3. if($price==='')
  4. {
  5. $price=0;
  6. }
  7. if ($change_price && defined('ECS_ADMIN') === false)
  8. {
  9. switch ($GLOBALS['_CFG']['price_format'])
  10. {
  11. case 0:
  12. $price = number_format($price, 2, '.', '');
  13. break;
  14. case 1: // 保留不为 0 的尾数
  15. $price = preg_replace('/(.*)(\\.)([0-9]*?)0+$/', '\1\2\3', number_format($price, 2, '.', ''));

  16. if (substr($price, -1) == '.')
  17. {
  18. $price = substr($price, 0, -1);
  19. }
  20. break;
  21. case 2: // 不四舍五入,保留1位
  22. $price = substr(number_format($price, 2, '.', ''), 0, -1);
  23. break;
  24. case 3: // 直接取整
  25. $price = intval($price);
  26. break;
  27. case 4: // 四舍五入,保留 1 位
  28. $price = number_format($price, 1, '.', '');
  29. break;
  30. case 5: // 先四舍五入,不保留小数
  31. $price = round($price);
  32. break;
  33. }
  34. }
  35. else
  36. {
  37. $price = number_format($price, 2, '.', '');
  38. }

  39. return sprintf($GLOBALS['_CFG']['currency_format'], $price);
  40. }
Sao chép mã

Thay thế bằng đoạn code sau:
  1. function price_format($price, $change_price = true)
  2. {
  3. if($price==='')
  4. {
  5. $price=0;
  6. }
  7. if ($change_price && defined('ECS_ADMIN') === false)
  8. {
  9. switch ($GLOBALS['_CFG']['price_format'])
  10. {
  11. case 0:
  12. $price = number_format($price, 0, ',', '.');
  13. break;
  14. case 1: // 保留不为 0 的尾数
  15. $price = preg_replace('/(.*)(\\.)([0-9]*?)0+$/', '\1\2\3', number_format($price, 0, ',', '.'));

  16. if (substr($price, -1) == '.')
  17. {
  18. $price = substr($price, 0, -1);
  19. }
  20. break;
  21. case 2: // 不四舍五入,保留1位
  22. $price = substr(number_format($price, 0, ',', '.'), 0, -1);
  23. break;
  24. case 3: // 直接取整
  25. $price = intval($price);
  26. break;
  27. case 4: // 四舍五入,保留 1 位
  28. $price = number_format($price, 0, ',', '.');
  29. break;
  30. case 5: // 先四舍五入,不保留小数
  31. $price = round($price);
  32. break;
  33. }
  34. }
  35. else
  36. {
  37. $price = number_format($price, 0, ',', '.');
  38. }

  39. return sprintf($GLOBALS['_CFG']['currency_format'], $price);
  40. }
Sao chép mã






Chào mừng ghé thăm Thẩm mỹ viện Uy Tín | Web Chăm sóc Gia Đình (http://www.chamsocgiadinh.com/) Powered by Discuz! X3.2