Author Topic: Rounding price custom fields problem after update to Joomla 2.5.16  (Read 10781 times)

Lockerbie

  • Jr. Member
  • **
  • Posts: 102
Good afternoon,

After updating to Joomla 2.5.16, the added price in the custom fields isn't showing correct anymore.

I have a dropdown custom field for gift wrapping. Before, it showed the choices: 'no giftwrapping' and 'yes, giftwrapping + € 1,50'.
But after the update the choice for 'yes...' shows 'yes, giftwrapping +1'. Besides that, the productprice updates correctly when choosing 'yes...'.

This seems to be a bug. So is using the backup (Joomla 2.5.14) really the best solution for this, as advised in the Dutch forum? Or does somebody here have a solution to this? Thanks.

J! 2.5.16 - VM 2.0.24

Maxim Pishnyak

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2657
Re: Rounding price custom fields problem after update to Joomla 2.5.16
« Reply #1 on: November 07, 2013, 19:19:58 pm »
Could you repost here some additional info from your thread on Dutch forum? I can't reach it from my country area.

Lockerbie

  • Jr. Member
  • **
  • Posts: 102
Re: Rounding price custom fields problem after update to Joomla 2.5.16
« Reply #2 on: November 07, 2013, 20:54:12 pm »
Hello Maxim,

There's no additional info, just a link to an example. But perhaps you can't reach that either, so I've made some printscreens.
In img1 there's the original productprice, the tax and the custom field dropdown. Here is chosen for 'no giftwrapping', so no extra costs.
In img2 is chosen for 'yes, giftwrapping'. The additional € 1,50 is added to the productprice, but isn't showing in the custom field dropdown anymore. Instead you just see 'yes +1'.

On the Dutch forum one user reacted saying he uses the same J!- and VM-versions and experienced the same problem. He chose to use the backup instead.
And a bit later one of the moderators said they also just found out that this is occuring and using the backup might be the best solution for now.

[attachment cleanup by admin]

Margriet

  • Jr. Member
  • **
  • Posts: 80
Re: Rounding price custom fields problem after update to Joomla 2.5.16
« Reply #3 on: November 07, 2013, 23:20:57 pm »
This might give you additional info
http://forum.virtuemart.net/index.php?topic=120119.0

Lockerbie

  • Jr. Member
  • **
  • Posts: 102
Re: Rounding price custom fields problem after update to Joomla 2.5.16
« Reply #4 on: November 09, 2013, 11:43:57 am »
Good morning!

I think I found something. That's to say: it's working, but I don't know if it is safe enough...
After comparing some files of the update-2.5.16-package with the ones in the 2.5.14-version, I noticed that file 'libraries/joomla/methods.php' is quite different. So I replaced the new one with the old one of the 2.5.14-version.
The result: when choosing 'giftwrapping', it now shows again: 'yes, +1,50 €'!

Please, can anyone tell me whether or not it is safe enough to use the 'old' file again? Thanks!

The 2.5.16-version:
Code: [Select]
<?php
/**
 * @package    Joomla.Platform
 *
 * @copyright  Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * Route handling class
 *
 * @package  Joomla.Platform
 * @since    11.1
 */
class JRoute
{
/**
 * Translates an internal Joomla URL to a humanly readible URL.
 *
 * @param   string   $url    Absolute or Relative URI to Joomla resource.
 * @param   boolean  $xhtml  Replace & by &amp; for XML compilance.
 * @param   integer  $ssl    Secure state for the resolved URI.
 *                             1: Make URI secure using global secure site URI.
 *                             0: Leave URI in the same secure state as it was passed to the function.
 *                            -1: Make URI unsecure using the global unsecure site URI.
 *
 * @return  The translated humanly readible URL.
 *
 * @since   11.1
 */
public static function _($url$xhtml true$ssl null)
{
// Get the router.
$app JFactory::getApplication();
$router $app->getRouter();

// Make sure that we have our router
if (!$router)
{
return null;
}

if ((strpos($url'&') !== 0) && (strpos($url'index.php') !== 0))
{
return $url;
}

// Build route.
$uri $router->build($url);
$url $uri->toString(array('path''query''fragment'));

// Replace spaces.
$url preg_replace('/\s/u''%20'$url);

/*
 * Get the secure/unsecure URLs.
 *
 * If the first 5 characters of the BASE are 'https', then we are on an ssl connection over
 * https and need to set our secure URL to the current request URL, if not, and the scheme is
 * 'http', then we need to do a quick string manipulation to switch schemes.
 */
if ((int) $ssl)
{
$uri JURI::getInstance();

// Get additional parts.
static $prefix;
if (!$prefix)
{
$prefix $uri->toString(array('host''port'));
}

// Determine which scheme we want.
$scheme = ((int) $ssl === 1) ? 'https' 'http';

// Make sure our URL path begins with a slash.
if (!preg_match('#^/#'$url))
{
$url '/' $url;
}

// Build the URL.
$url $scheme '://' $prefix $url;
}

if ($xhtml)
{
$url htmlspecialchars($url);
}

return $url;
}
}

/**
 * Text  handling class.
 *
 * @package     Joomla.Platform
 * @subpackage  Language
 * @since       11.1
 */
class JText
{
/**
 * javascript strings
 *
 * @var    array
 * @since  11.1
 */
protected static $strings = array();

/**
 * Translates a string into the current language.
 *
 * Examples:
 * <script>alert(Joomla.JText._('<?php echo JText::_("JDEFAULT", array("script"=>true));?>
'));</script>
* will generate an alert message containing 'Default'
* <?php echo JText::_("JDEFAULT");?> it will generate a 'Default' string
*
* @param   string   $string                The string to translate.
* @param   mixed    $jsSafe                Boolean: Make the result javascript safe.
* @param   boolean  $interpretBackSlashes  To interpret backslashes (\\=\, \n=carriage return, \t=tabulation)
* @param   boolean  $script                To indicate that the string will be push in the javascript language store
*
* @return  string  The translated string or the key is $script is true
*
* @since   11.1
*/
public static function _($string, $jsSafe = false, $interpretBackSlashes = true, $script = false)
{
$lang = JFactory::getLanguage();
if (is_array($jsSafe))
{
if (array_key_exists('interpretBackSlashes', $jsSafe))
{
$interpretBackSlashes = (boolean) $jsSafe['interpretBackSlashes'];
}
if (array_key_exists('script', $jsSafe))
{
$script = (boolean) $jsSafe['script'];
}
if (array_key_exists('jsSafe', $jsSafe))
{
$jsSafe = (boolean) $jsSafe['jsSafe'];
}
else
{
$jsSafe = false;
}
}
if (!(strpos($string, ',') === false))
{
$test = substr($string, strpos($string, ','));
if (strtoupper($test) === $test)
{
$strs = explode(',', $string);
foreach ($strs as $i => $str)
{
$strs[$i] = $lang->_($str, $jsSafe, $interpretBackSlashes);
if ($script)
{
self::$strings[$str] = $strs[$i];
}
}
$str = array_shift($strs);
$str = preg_replace('/\[\[%([0-9]+):[^\]]*\]\]/', '%\1$s', $str);
$str = vsprintf($str, $strs);

return $str;
}
}
if ($script)
{
self::$strings[$string] = $lang->_($string, $jsSafe, $interpretBackSlashes);
return $string;
}
else
{
return $lang->_($string, $jsSafe, $interpretBackSlashes);
}
}

/**
* Translates a string into the current language.
*
* Examples:
* <?php echo JText::alt("JALL","language");?> it will generate a 'All' string in English but a "Toutes" string in French
* <?php echo JText::alt("JALL","module");?> it will generate a 'All' string in English but a "Tous" string in French
*
* @param   string   $string                The string to translate.
* @param   string   $alt                   The alternate option for global string
* @param   mixed    $jsSafe                Boolean: Make the result javascript safe.
* @param   boolean  $interpretBackSlashes  To interpret backslashes (\\=\, \n=carriage return, \t=tabulation)
* @param   boolean  $script                To indicate that the string will be pushed in the javascript language store
*
* @return  string  The translated string or the key if $script is true
*
* @since   11.1
*/
public static function alt($string, $alt, $jsSafe = false, $interpretBackSlashes = true, $script = false)
{
$lang = JFactory::getLanguage();
if ($lang->hasKey($string . '_' . $alt))
{
return self::_($string . '_' . $alt, $jsSafe, $interpretBackSlashes);
}
else
{
return self::_($string, $jsSafe, $interpretBackSlashes);
}
}
/**
* Like JText::sprintf but tries to pluralise the string.
*
* Note that this method can take a mixed number of arguments as for the sprintf function.
*
* The last argument can take an array of options:
*
* array('jsSafe'=>boolean, 'interpretBackSlashes'=>boolean, 'script'=>boolean)
*
* where:
*
* jsSafe is a boolean to generate a javascript safe strings.
* interpretBackSlashes is a boolean to interpret backslashes \\->\, \n->new line, \t->tabulation.
* script is a boolean to indicate that the string will be push in the javascript language store.
*
* Examples:
* <script>alert(Joomla.JText._('<?php echo JText::plural("COM_PLUGINS_N_ITEMS_UNPUBLISHED"1, array("script"=>true));?>'));</script>
* will generate an alert message containing '1 plugin successfully disabled'
* <?php echo JText::plural("COM_PLUGINS_N_ITEMS_UNPUBLISHED"1);?> it will generate a '1 plugin successfully disabled' string
*
* @param   string   $string  The format string.
* @param   integer  $n       The number of items
*
* @return  string  The translated strings or the key if 'script' is true in the array of options
*
* @since   11.1
*/
public static function plural($string, $n)
{
$lang = JFactory::getLanguage();
$args = func_get_args();
$count = count($args);

if ($count > 1)
{
// Try the key from the language plural potential suffixes
$found = false;
$suffixes = $lang->getPluralSuffixes((int) $n);
array_unshift($suffixes, (int) $n);
foreach ($suffixes as $suffix)
{
$key = $string . '_' . $suffix;
if ($lang->hasKey($key))
{
$found = true;
break;
}
}
if (!$found)
{
// Not found so revert to the original.
$key = $string;
}
if (is_array($args[$count - 1]))
{
$args[0] = $lang->_(
$key, array_key_exists('jsSafe', $args[$count - 1]) ? $args[$count - 1]['jsSafe'] : false,
array_key_exists('interpretBackSlashes', $args[$count - 1]) ? $args[$count - 1]['interpretBackSlashes'] : true
);
if (array_key_exists('script', $args[$count - 1]) && $args[$count - 1]['script'])
{
self::$strings[$key] = call_user_func_array('sprintf', $args);
return $key;
}
}
else
{
$args[0] = $lang->_($key);
}
return call_user_func_array('sprintf', $args);
}
elseif ($count > 0)
{

// Default to the normal sprintf handling.
$args[0] = $lang->_($string);
return call_user_func_array('sprintf', $args);
}

return '';
}

/**
* Passes a string thru a sprintf.
*
* Note that this method can take a mixed number of arguments as for the sprintf function.
*
* The last argument can take an array of options:
*
* array('jsSafe'=>boolean, 'interpretBackSlashes'=>boolean, 'script'=>boolean)
*
* where:
*
* jsSafe is a boolean to generate a javascript safe strings.
* interpretBackSlashes is a boolean to interpret backslashes \\->\, \n->new line, \t->tabulation.
* script is a boolean to indicate that the string will be push in the javascript language store.
*
* @param   string  $string  The format string.
*
* @return  string  The translated strings or the key if 'script' is true in the array of options.
*
* @since   11.1
*/
public static function sprintf($string)
{
$lang = JFactory::getLanguage();
$args = func_get_args();
$count = count($args);
if ($count > 0)
{
if (is_array($args[$count - 1]))
{
$args[0] = $lang->_(
$string, array_key_exists('jsSafe', $args[$count - 1]) ? $args[$count - 1]['jsSafe'] : false,
array_key_exists('interpretBackSlashes', $args[$count - 1]) ? $args[$count - 1]['interpretBackSlashes'] : true
);

if (array_key_exists('script', $args[$count - 1]) && $args[$count - 1]['script'])
{
self::$strings[$string] = call_user_func_array('sprintf', $args);
return $string;
}
}
else
{
$args[0] = $lang->_($string);
}
$args[0] = preg_replace('/\[\[%([0-9]+):[^\]]*\]\]/', '%\1$s', $args[0]);
return call_user_func_array('sprintf', $args);
}
return '';
}

/**
* Passes a string thru an printf.
*
* Note that this method can take a mixed number of arguments as for the sprintf function.
*
* @param   format  $string  The format string.
*
* @return  mixed
*
* @since   11.1
*/
public static function printf($string)
{
$lang = JFactory::getLanguage();
$args = func_get_args();
$count = count($args);
if ($count > 0)
{
if (is_array($args[$count - 1]))
{
$args[0] = $lang->_(
$string, array_key_exists('jsSafe', $args[$count - 1]) ? $args[$count - 1]['jsSafe'] : false,
array_key_exists('interpretBackSlashes', $args[$count - 1]) ? $args[$count - 1]['interpretBackSlashes'] : true
);
}
else
{
$args[0] = $lang->_($string);
}
return call_user_func_array('printf', $args);
}
return '';
}

/**
* Translate a string into the current language and stores it in the JavaScript language store.
*
* @param   string   $string                The JText key.
* @param   boolean  $jsSafe                Ensure the output is JavaScript safe.
* @param   boolean  $interpretBackSlashes  Interpret \t and \n.
*
* @return  string
*
* @since   11.1
*/
public static function script($string = null, $jsSafe = false, $interpretBackSlashes = true)
{
if (is_array($jsSafe))
{
if (array_key_exists('interpretBackSlashes', $jsSafe))
{
$interpretBackSlashes = (boolean) $jsSafe['interpretBackSlashes'];
}

if (array_key_exists('jsSafe', $jsSafe))
{
$jsSafe = (boolean) $jsSafe['jsSafe'];
}
else
{
$jsSafe = false;
}
}

// Add the string to the array if not null.
if ($string !== null)
{
// Normalize the key and translate the string.
self::$strings[strtoupper($string)] = JFactory::getLanguage()->_($string, $jsSafe, $interpretBackSlashes);
}

return self::$strings;
}
}

Lockerbie

  • Jr. Member
  • **
  • Posts: 102
Re: Rounding price custom fields problem after update to Joomla 2.5.16
« Reply #5 on: November 09, 2013, 11:44:29 am »
And the 2.5.14-version:
Code: [Select]
<?php
/**
 * @package    Joomla.Platform
 *
 * @copyright  Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * Route handling class
 *
 * @package  Joomla.Platform
 * @since    11.1
 */
class JRoute
{
/**
 * Translates an internal Joomla URL to a humanly readible URL.
 *
 * @param   string   $url    Absolute or Relative URI to Joomla resource.
 * @param   boolean  $xhtml  Replace & by &amp; for XML compilance.
 * @param   integer  $ssl    Secure state for the resolved URI.
 *                             1: Make URI secure using global secure site URI.
 *                             0: Leave URI in the same secure state as it was passed to the function.
 *                            -1: Make URI unsecure using the global unsecure site URI.
 *
 * @return  The translated humanly readible URL.
 *
 * @since   11.1
 */
public static function _($url$xhtml true$ssl null)
{
// Get the router.
$app JFactory::getApplication();
$router $app->getRouter();

// Make sure that we have our router
if (!$router)
{
return null;
}

if ((strpos($url'&') !== 0) && (strpos($url'index.php') !== 0))
{
return $url;
}

// Build route.
$uri $router->build($url);
$url $uri->toString(array('path''query''fragment'));

// Replace spaces.
$url preg_replace('/\s/u''%20'$url);

/*
 * Get the secure/unsecure URLs.
 *
 * If the first 5 characters of the BASE are 'https', then we are on an ssl connection over
 * https and need to set our secure URL to the current request URL, if not, and the scheme is
 * 'http', then we need to do a quick string manipulation to switch schemes.
 */
if ((int) $ssl)
{
$uri JURI::getInstance();

// Get additional parts.
static $prefix;
if (!$prefix)
{
$prefix $uri->toString(array('host''port'));
}

// Determine which scheme we want.
$scheme = ((int) $ssl === 1) ? 'https' 'http';

// Make sure our URL path begins with a slash.
if (!preg_match('#^/#'$url))
{
$url '/' $url;
}

// Build the URL.
$url $scheme '://' $prefix $url;
}

if ($xhtml)
{
$url htmlspecialchars($url);
}

return $url;
}
}

/**
 * Text  handling class.
 *
 * @package     Joomla.Platform
 * @subpackage  Language
 * @since       11.1
 */
class JText
{
/**
 * javascript strings
 *
 * @var    array
 * @since  11.1
 */
protected static $strings = array();

/**
 * Translates a string into the current language.
 *
 * Examples:
 * <script>alert(Joomla.JText._('<?php echo JText::_("JDEFAULT", array("script"=>true));?>
'));</script>
* will generate an alert message containing 'Default'
* <?php echo JText::_("JDEFAULT");?> it will generate a 'Default' string
*
* @param   string   $string                The string to translate.
* @param   mixed    $jsSafe                Boolean: Make the result javascript safe.
* @param   boolean  $interpretBackSlashes  To interpret backslashes (\\=\, \n=carriage return, \t=tabulation)
* @param   boolean  $script                To indicate that the string will be push in the javascript language store
*
* @return  string  The translated string or the key is $script is true
*
* @since   11.1
*/
public static function _($string, $jsSafe = false, $interpretBackSlashes = true, $script = false)
{
$lang = JFactory::getLanguage();
if (is_array($jsSafe))
{
if (array_key_exists('interpretBackSlashes', $jsSafe))
{
$interpretBackSlashes = (boolean) $jsSafe['interpretBackSlashes'];
}
if (array_key_exists('script', $jsSafe))
{
$script = (boolean) $jsSafe['script'];
}
if (array_key_exists('jsSafe', $jsSafe))
{
$jsSafe = (boolean) $jsSafe['jsSafe'];
}
else
{
$jsSafe = false;
}
}
if ($script)
{
self::$strings[$string] = $lang->_($string, $jsSafe, $interpretBackSlashes);
return $string;
}
else
{
return $lang->_($string, $jsSafe, $interpretBackSlashes);
}
}

/**
* Translates a string into the current language.
*
* Examples:
* <?php echo JText::alt("JALL","language");?> it will generate a 'All' string in English but a "Toutes" string in French
* <?php echo JText::alt("JALL","module");?> it will generate a 'All' string in English but a "Tous" string in French
*
* @param   string   $string                The string to translate.
* @param   string   $alt                   The alternate option for global string
* @param   mixed    $jsSafe                Boolean: Make the result javascript safe.
* @param   boolean  $interpretBackSlashes  To interpret backslashes (\\=\, \n=carriage return, \t=tabulation)
* @param   boolean  $script                To indicate that the string will be pushed in the javascript language store
*
* @return  string  The translated string or the key if $script is true
*
* @since   11.1
*/
public static function alt($string, $alt, $jsSafe = false, $interpretBackSlashes = true, $script = false)
{
$lang = JFactory::getLanguage();
if ($lang->hasKey($string . '_' . $alt))
{
return self::_($string . '_' . $alt, $jsSafe, $interpretBackSlashes);
}
else
{
return self::_($string, $jsSafe, $interpretBackSlashes);
}
}
/**
* Like JText::sprintf but tries to pluralise the string.
*
* Note that this method can take a mixed number of arguments as for the sprintf function.
*
* The last argument can take an array of options:
*
* array('jsSafe'=>boolean, 'interpretBackSlashes'=>boolean, 'script'=>boolean)
*
* where:
*
* jsSafe is a boolean to generate a javascript safe strings.
* interpretBackSlashes is a boolean to interpret backslashes \\->\, \n->new line, \t->tabulation.
* script is a boolean to indicate that the string will be push in the javascript language store.
*
* Examples:
* <script>alert(Joomla.JText._('<?php echo JText::plural("COM_PLUGINS_N_ITEMS_UNPUBLISHED"1, array("script"=>true));?>'));</script>
* will generate an alert message containing '1 plugin successfully disabled'
* <?php echo JText::plural("COM_PLUGINS_N_ITEMS_UNPUBLISHED"1);?> it will generate a '1 plugin successfully disabled' string
*
* @param   string   $string  The format string.
* @param   integer  $n       The number of items
*
* @return  string  The translated strings or the key if 'script' is true in the array of options
*
* @since   11.1
*/
public static function plural($string, $n)
{
$lang = JFactory::getLanguage();
$args = func_get_args();
$count = count($args);

if ($count > 1)
{
// Try the key from the language plural potential suffixes
$found = false;
$suffixes = $lang->getPluralSuffixes((int) $n);
array_unshift($suffixes, (int) $n);
foreach ($suffixes as $suffix)
{
$key = $string . '_' . $suffix;
if ($lang->hasKey($key))
{
$found = true;
break;
}
}
if (!$found)
{
// Not found so revert to the original.
$key = $string;
}
if (is_array($args[$count - 1]))
{
$args[0] = $lang->_(
$key, array_key_exists('jsSafe', $args[$count - 1]) ? $args[$count - 1]['jsSafe'] : false,
array_key_exists('interpretBackSlashes', $args[$count - 1]) ? $args[$count - 1]['interpretBackSlashes'] : true
);
if (array_key_exists('script', $args[$count - 1]) && $args[$count - 1]['script'])
{
self::$strings[$key] = call_user_func_array('sprintf', $args);
return $key;
}
}
else
{
$args[0] = $lang->_($key);
}
return call_user_func_array('sprintf', $args);
}
elseif ($count > 0)
{

// Default to the normal sprintf handling.
$args[0] = $lang->_($string);
return call_user_func_array('sprintf', $args);
}

return '';
}

/**
* Passes a string thru a sprintf.
*
* Note that this method can take a mixed number of arguments as for the sprintf function.
*
* The last argument can take an array of options:
*
* array('jsSafe'=>boolean, 'interpretBackSlashes'=>boolean, 'script'=>boolean)
*
* where:
*
* jsSafe is a boolean to generate a javascript safe strings.
* interpretBackSlashes is a boolean to interpret backslashes \\->\, \n->new line, \t->tabulation.
* script is a boolean to indicate that the string will be push in the javascript language store.
*
* @param   string  $string  The format string.
*
* @return  string  The translated strings or the key if 'script' is true in the array of options.
*
* @since   11.1
*/
public static function sprintf($string)
{
$lang = JFactory::getLanguage();
$args = func_get_args();
$count = count($args);
if ($count > 0)
{
if (is_array($args[$count - 1]))
{
$args[0] = $lang->_(
$string, array_key_exists('jsSafe', $args[$count - 1]) ? $args[$count - 1]['jsSafe'] : false,
array_key_exists('interpretBackSlashes', $args[$count - 1]) ? $args[$count - 1]['interpretBackSlashes'] : true
);

if (array_key_exists('script', $args[$count - 1]) && $args[$count - 1]['script'])
{
self::$strings[$string] = call_user_func_array('sprintf', $args);
return $string;
}
}
else
{
$args[0] = $lang->_($string);
}
return call_user_func_array('sprintf', $args);
}
return '';
}

/**
* Passes a string thru an printf.
*
* Note that this method can take a mixed number of arguments as for the sprintf function.
*
* @param   format  $string  The format string.
*
* @return  mixed
*
* @since   11.1
*/
public static function printf($string)
{
$lang = JFactory::getLanguage();
$args = func_get_args();
$count = count($args);
if ($count > 0)
{
if (is_array($args[$count - 1]))
{
$args[0] = $lang->_(
$string, array_key_exists('jsSafe', $args[$count - 1]) ? $args[$count - 1]['jsSafe'] : false,
array_key_exists('interpretBackSlashes', $args[$count - 1]) ? $args[$count - 1]['interpretBackSlashes'] : true
);
}
else
{
$args[0] = $lang->_($string);
}
return call_user_func_array('printf', $args);
}
return '';
}

/**
* Translate a string into the current language and stores it in the JavaScript language store.
*
* @param   string   $string                The JText key.
* @param   boolean  $jsSafe                Ensure the output is JavaScript safe.
* @param   boolean  $interpretBackSlashes  Interpret \t and \n.
*
* @return  string
*
* @since   11.1
*/
public static function script($string = null, $jsSafe = false, $interpretBackSlashes = true)
{
if (is_array($jsSafe))
{
if (array_key_exists('interpretBackSlashes', $jsSafe))
{
$interpretBackSlashes = (boolean) $jsSafe['interpretBackSlashes'];
}

if (array_key_exists('jsSafe', $jsSafe))
{
$jsSafe = (boolean) $jsSafe['jsSafe'];
}
else
{
$jsSafe = false;
}
}

// Add the string to the array if not null.
if ($string !== null)
{
// Normalize the key and translate the string.
self::$strings[strtoupper($string)] = JFactory::getLanguage()->_($string, $jsSafe, $interpretBackSlashes);
}

return self::$strings;
}
}

jurajvt

  • Beginner
  • *
  • Posts: 21
Re: Rounding price custom fields problem after update to Joomla 2.5.16
« Reply #6 on: November 09, 2013, 16:36:08 pm »
It is not rounding price, just cutting off all after a comma in displayed text for HTML select option, value is unaffected.  It can better sanitizing data against javascript exploits. It has nothing to do with PHP version.

Unfortunatelly, it is a problem, which we now must to resolve without hacking.

One quick possible solution is to change currency decimal delimiter to point (dot).

Or, if you want to use a comma in your currency, do a little change in administrator/components/com_virtuemart/models/customfields.php around line 898:

from: $productCustom->text = $productCustom->custom_value . ' ' . $price;
to: $productCustom->text = JText::_($productCustom->custom_value) . ' ' . str_replace(",", "&#44;", $price);

It is better to let core Joomla files as they are.

servlet

  • Jr. Member
  • **
  • Posts: 348
  • Business optimization
    • Фототапети
  • VirtueMart Version: 3.2.2
Re: Rounding price custom fields problem after update to Joomla 2.5.16
« Reply #7 on: November 09, 2013, 16:53:14 pm »
I have the same problem.
My delimiter is point.
It is a bug
We need quick new version with this bug fix
I am using: Joomla 3.7.2 VM 3.2.2
Он-лайн магазин за фототапети http://mishelfoster.com

jurajvt

  • Beginner
  • *
  • Posts: 21
Re: Rounding price custom fields problem after update to Joomla 2.5.16
« Reply #8 on: November 09, 2013, 17:06:30 pm »
I have the same problem.
My delimiter is point.
It is a bug
We need quick new version with this bug fix

It is not possible, because added core sanitizing is affecting only comma mark, other is untouched. Try to find your current currency in virtuemart and change its decimal to radix point.

I tried both of my fix methods, and all is working.

servlet

  • Jr. Member
  • **
  • Posts: 348
  • Business optimization
    • Фототапети
  • VirtueMart Version: 3.2.2
Re: Rounding price custom fields problem after update to Joomla 2.5.16
« Reply #9 on: November 09, 2013, 17:47:43 pm »
I do it. It works. But it needs to be changet for all VM users? how? with new version.
Let we think for all. Somebody maybe doesnt know....
Thanks for your idea. I fixed my shops.
I am using: Joomla 3.7.2 VM 3.2.2
Он-лайн магазин за фототапети http://mishelfoster.com

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9843
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Rounding price custom fields problem after update to Joomla 2.5.16
« Reply #10 on: November 11, 2013, 11:18:18 am »
It is not possible, because added core sanitizing is affecting only comma mark, other is untouched. Try to find your current currency in virtuemart and change its decimal to radix point.

Why do you think this, which code do you mean?

I cannot reproduce this error. I have now latest joomla version and 2.0.24a and php 5.4.7
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Margriet

  • Jr. Member
  • **
  • Posts: 80
Re: Rounding price custom fields problem after update to Joomla 2.5.16
« Reply #11 on: November 11, 2013, 12:07:27 pm »
Where do I download 2.0.24a? Latest version on downloads is 2.0.24. I have now another site where my customer added some special fields himself. Even stranger behaviour. When I looked at the site yesterday I saw all prices with decimals. Decided to change one price and that one is now showing without decimals. Copied site to my own localhost environment (PHP 5.4.17), exactly the same as on live environment (PHP 5.3.10).

[attachment cleanup by admin]

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9843
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Rounding price custom fields problem after update to Joomla 2.5.16
« Reply #12 on: November 11, 2013, 12:14:40 pm »
I think I know now why. I big problems is also the precision. The new version sets the precision to 15. Please try
Code: [Select]
ini_set('precision', 15);
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

jurajvt

  • Beginner
  • *
  • Posts: 21
Re: Rounding price custom fields problem after update to Joomla 2.5.16
« Reply #13 on: November 11, 2013, 14:11:01 pm »
It is not possible, because added core sanitizing is affecting only comma mark, other is untouched. Try to find your current currency in virtuemart and change its decimal to radix point.

Why do you think this, which code do you mean?

I cannot reproduce this error. I have now latest joomla version and 2.0.24a and php 5.4.7

method.php, which you can see in code above... There is a new condition in JText::_ added to search comma in input...

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9843
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Rounding price custom fields problem after update to Joomla 2.5.16
« Reply #14 on: November 11, 2013, 15:07:11 pm »
Code: [Select]
if (!(strpos($string, ',') === false))
{
$test = substr($string, strpos($string, ','));
if (strtoupper($test) === $test)
{
$strs = explode(',', $string);
foreach ($strs as $i => $str)
{
$strs[$i] = $lang->_($str, $jsSafe, $interpretBackSlashes);
if ($script)
{
self::$strings[$str] = $strs[$i];
}
}
$str = array_shift($strs);
$str = preg_replace('/\[\[%([0-9]+):[^\]]*\]\]/', '%\1$s', $str);
$str = vsprintf($str, $strs);

return $str;
}
}

Looks like the sanitize there something, but that means you cannot have a Comma, or a description with more than one Comma in it. Seems to be some security thing. But in fact, it is wrong to sanitize this kinds of values. It must be prevented that this function is called wrong.

It seems there must not be any digits at the end. If you have a "," in your string it is seperated in segments. If any of the segments is in upper case the same as in lower case, it maybe removed. Solution? add some char to the segment which is pure numbers, haha.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/