X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Changes Product Format - Decimal Places (https://forum.x-cart.com/showthread.php?t=77871)

LTucker 06-17-2020 08:47 AM

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.

Ed B. 07-01-2020 07:18 AM

Re: Changes Product Format - Decimal Places
 
I think you will have to change the value of the column "e" in the table xc_currencies of your x-cart database for the currency you are using from 2 to 4.


All times are GMT -8. The time now is 08:04 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.