Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Changes Product Format - Decimal Places

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #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
  #2  
Old 07-01-2020, 07:18 AM
 
Ed B. Ed B. is online now
 

X-Adept
  
Join Date: Apr 2016
Posts: 453
 

Default 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.
__________________
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:45 PM.

   

 
X-Cart forums © 2001-2020