News:

Looking for documentation? Take a look on our wiki

Main Menu

Change decimal price displaying with superscript tag <sup> or <sub>

Started by lipes, January 12, 2012, 21:09:20 PM

Previous topic - Next topic

lipes

Hello ppl.
I want to change all displayed price, for example, from the normal: 10.00€ to 10.00€ or 10.00
Adding just the <sup> </ sup> or the <sub> </ sub> tag, or minimizing the CSS font-size.... in the decimal values (Front End)...

What file we need to edit/change in VM2.0 ?
Examples of sites that have this feature in the prices
http://www.electrodepot.fr/
http://www.cobrason.com/

Thanks for any possible help!

VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

dboror

In your Joomla! template create a default.php file

yoursite.com/templates/yourtemplate/html/com_virtuemart/productdetails/default.php and copy this

<?php
/**
*
* Show the products in a category
*
* @package    VirtueMart
* @subpackage
* @author RolandD
* @author Max Milbers
* @todo add pagination
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: default.php 2710 2011-02-13 00:51:06Z Electrocity $
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

if (
$this->category->haschildren) {

// Category and Columns Counter
$iCol 1;
$iCategory 1;

// Calculating Categories Per Row
$categories_per_row VmConfig::get 'categories_per_row');
$category_cellwidth ' width'.floor 100 $categories_per_row );

// Separator
$verticalseparator " vertical-separator";
?>


<div class="category-view">

<?php // Start the Output
foreach ( $this->category->children as $category ) {

// Show the horizontal seperator
if ($iCol == && $iCategory $categories_per_row) { ?>

<div class="horizontal-separator"></div>
<?php }

// this is an indicator wether a row needs to be opened or not
if ($iCol == 1) { ?>

<div class="row">
<?php }

// Show the vertical seperator
if ($iCategory == $categories_per_row or $iCategory $categories_per_row == 0) {
$show_vertical_separator ' ';
} else {
$show_vertical_separator $verticalseparator;
}

// Category Link
$caturl JRoute::'index.php?option=com_virtuemart&view=category&virtuemart_category_id=' $category->virtuemart_category_id );

// Show Category ?>

<div class="category floatleft<?php echo $category_cellwidth $show_vertical_separator ?>">
<div class="spacer">
<h2>
<a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
<?php echo $category->category_name ?>
<br />
<?php // if ($category->ids) {
echo $category->images[0]->displayMediaThumb("",false);
//} ?>

</a>
</h2>
</div>
</div>
<?php
$iCategory ++;

// Do we need to close the current row now?
if ($iCol == $categories_per_row) { ?>

<div class="clear"></div>
</div>
<?php
$iCol 1;
} else {
$iCol ++;
}
}
// Do we need a final closing row tag?
if ($iCol != 1) { ?>

<div class="clear"></div>
</div>
<?php
}
?>

</div>
<?php ?>




alatak

Hi,

QuoteI want to change all the displaying prices, for example from the normal: 10.00€   to   10.€00.
I only need to insert the <sup> </sup> in the decimal values and in the € / $

What file i need to edit/change in VM2.0 ?

Go in Configuration > Currencies, and change the fields Positive format, and negative format

lipes

Thanks for helping Alatak! :)
I only want to change only the decimals value.
Positive format, and negative format doesnt do want i intend to...

I need to change the {number} in decimals value, who its possible to edit to add a simple <sup></sup> or <sub></sub>?
VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

alatak

Hi,

No , you are rigth it is not possible. {number} includes the decimal.

tobisagt

Hi,

iam also interested in this question and was searching a bit.

Take a look in the currencydisplay.php in administrator/components/com_virtuemart/helpers/

Maybe its here?!

tobisagt


sirius

Hi,

I know this is not the most elegant way to do it, but it's simple and it works.
In your template default_showprices.php line 47 or where you need it.

<?php
$pricebef 
$this->currency->createPriceDiv ('salesPrice''COM_VIRTUEMART_PRODUCT_SALESPRICE'$this->product->prices);
$firstpart current(explode(','$pricebef));
$lastpart end(explode(','$pricebef));
$lastpart '<sup>'.$lastpart.'</sup>';
$pricesup $firstpart.','.$lastpart;
//echo $this->currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $this->product->prices);
echo $pricesup;
?>



this could be translate into a little function to use it when needed.

But I think that the {number} tag should be split in three parts like: {number}{sep}{decimals} as we can use html in the currency editor, and so we could do as wee need.

{number} (number before the separator}
{sep} (the separator : comma or point}
{decimals} (decimals so...}
J3.10.12 | PHP 7.4.33 + APC + memcached + Opcode
VM Prod : 3.8.6 | VM Test : 4.0.12.10777