Jump to content

How to transform parts of the price information? [SOLVED]


scalesplanet.com

Recommended Posts

Hello PS users,

 

I'm trying to transform part of the price display of the product. class="our_price_display" to be more precise. This is what you would see displayed by PS, for example:

 

80,50 € tax.incl.

 

I want to style:

"80,50" style 1 (Typography 1)

"€" style 2 (Typography 2)

"tax.incl." style 3 (Typorgraphy 1 / Different size and placement)

 

So I want three different styles in that same sentence. The problem that I encounter is that this information comes from one function, I think $priceDisplay. As I cannot find the html of this information or where the content is I cannot separate them into different classes.

 

How and where could I find this information??

What would your advise be??

 

I want to do many of these sort of changes so if I learn how to do one perfectly it would be very useful. The problem I have no idea...

 

Dani

 

P.D. This is the code that displays the prices:

 

 

 

<span class="our_price_display">
{if $priceDisplay >= 0 && $priceDisplay <= 2}
<span id="our_price_display">{convertPrice price=$productPrice}</span>
{if $tax_enabled  && ((isset($display_tax_label) && $display_tax_label == 1) OR !isset($display_tax_label))}
{if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if}
{/if}
{/if}
</span>

Edited by scalesplanet.com (see edit history)
Link to comment
Share on other sites

Hello Ps users,

 

No need of your help. I found out at least how to transform the euro sign. You need to override your tools.php. So create a file "Tools.php" in the override folder. Code 1 is my entire code and code 2 is the added code I put, and the key to how to manipuly with CSS as you wish part of the price value. You need to assign a class and from there you can use your knowledge of CSS. I hope it helps somebody!!!

 

Code 2:

 

$c_char = '<span class="eurosign">'.$c_char.'</span>';

 

Code 1:

 

 

<?php

class Tools extends ToolsCore
{
public static function displayPrice($price, $currency = NULL, $no_utf8 = false)
{
if ($currency === NULL)
$currency = Currency::getCurrent();
/* if you modified this function, don't forget to modify the Javascript function formatCurrency (in tools.js) */
if (is_int($currency))
$currency = Currency::getCurrencyInstance((int)$currency);

if (is_array($currency))
{
$c_char = $currency['sign'];
$c_format = $currency['format'];
$c_decimals = (int)$currency['decimals'] * _PS_PRICE_DISPLAY_PRECISION_;
$c_blank = $currency['blank'];
}
elseif (is_object($currency))
{
$c_char = $currency->sign;
$c_format = $currency->format;
$c_decimals = (int)$currency->decimals * _PS_PRICE_DISPLAY_PRECISION_;
$c_blank = $currency->blank;
}
else
return false;

/* To Daniel: change here the class name of the currency symbol */
$c_char = '<span class="eurosign">'.$c_char.'</span>';

$blank = ($c_blank ? ' ' : '');
$ret = 0;
if (($isNegative = ($price < 0)))
$price *= -1;
$price = self::ps_round($price, $c_decimals);
switch ($c_format)
{
   /* X 0,000.00 */
   case 1:
$ret = $c_char.$blank.number_format($price, $c_decimals, '.', ',');
break;
/* 0 000,00 X*/
case 2:
$ret = number_format($price, $c_decimals, ',', ' ').$blank.$c_char;
break;
/* X 0.000,00 */
case 3:
$ret = $c_char.$blank.number_format($price, $c_decimals, ',', '.');
break;
/* 0,000.00 X */
case 4:
$ret = number_format($price, $c_decimals, '.', ',').$blank.$c_char;
break;
}
if ($isNegative)
$ret = '-'.$ret;
if ($no_utf8)
return str_replace('€', chr(128), $ret);
return $ret;
}
}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...