View Single Post
  #1  
Old 06-17-2020, 08:47 AM
 
LTucker LTucker is offline
 

Member
  
Join Date: Mar 2020
Posts: 14
 

Default Changes Product Format - Decimal Places

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.
__________________
Larry Tucker
Programmer Analyst, WPG Americas Inc.

X-Cart v5.4.0.1 [Linux]
Reply With Quote