I'm trying to increase the allowed decimal places for displayed product prices to four.
Following the developer documentation, I have tried decorating AView and modifying the function formatPrice(). I have also tried decorating Math and modifying the $precision values. Both attempts have been unsuccessful, and did not effect the default business logic in any way.
Code:
<?php
// vim: set ts=4 sw=4 sts=4 et:
namespace Developer\FormatDisplayPrice\View;
/**
* Abstract widget
*/
abstract class AView extends \XLite\View\AView implements \XLite\Base\IDecorator
{
/**
* Format price
*
* @param float $value Price
* @param \XLite\Model\Currency $currency Currency OPTIONAL
* @param boolean $strictFormat Flag if the price format is strict (trailing zeroes and so on options)
*
* @return string
*/
public static function formatPrice($value, \XLite\Model\Currency $currency = null, $strictFormat = false)
{
if (null === $currency) {
$currency = \XLite::getInstance()->getCurrency();
}
if ($currency->getRoundUp() !== \XLite\Model\Currency::ROUNDUP_NONE && !\XLite::isAdminZone()) {
$pow = pow(10, (int) $currency->getRoundUp());
$value = ceil($value * $pow) / $pow;
}
$parts = $currency->formatParts($value);
if (isset($parts['sign']) && '-' === $parts['sign']) {
$parts['sign'] = '− ';
}
if ($strictFormat) {
$parts = static::formatPartsStrictly($parts);
}
/*
* initial test
* return unformatted prices
*/
return $value;
}
}
Do these classes need to be decorated in a different manner?
Am I decorating the correct classes and/or functions for this problem?
Any help or guidance is appreciated.