Advertisement:

Author Topic: FIXED Currency simbol smaller  (Read 1820 times)

Adyyda

  • Sr. Member
  • ****
  • Posts: 435
FIXED Currency simbol smaller
« on: May 23, 2015, 01:01:54 pm »
Hello. Does anyone know how to make the currency simbol smaller than the price whithout changing core files?
« Last Edit: May 23, 2015, 02:42:06 pm by Adyyda »

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Currency simbol smaller
« Reply #1 on: May 23, 2015, 01:11:01 pm »
I don't think so, core files use the currency symbols set in Admin which is a charakter.  ???

Regards,
Eric

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Currency simbol smaller
« Reply #2 on: May 23, 2015, 02:37:23 pm »
Hi,

There is a filter that may be used for that.

Add this at the very bottom of your theme functions.php (take care not to leave blank lines after this):

Code: [Select]
<?php
function cust_resize_currency($currencyFormat) {
    
$currency preg_replace('~([\d\.,])~u'''$currencyFormat);
    
$currencyFormat str_replace($currency'<span style="font-size: 80%;">'.$currency.'</span>'$currencyFormat);
    return 
$currencyFormat
}

osc_add_filter('item_price''cust_resize_currency');
?>


Play with that "font-size: 80%;" until you find a suitable look on every page where price is printed (although this could still be refined to change value depending on page type).

Regards

Adyyda

  • Sr. Member
  • ****
  • Posts: 435
Re: Currency simbol smaller
« Reply #3 on: May 23, 2015, 02:38:47 pm »
Hi,

There is a filter that may be used for that.

Add this at the very bottom of your theme functions.php (take care not to leave blank lines after this):

Code: [Select]
<?php
function cust_resize_currency$currencyFormat) {
    
$currency preg_replace('~([\d\.,])~u'''$currencyFormat);
    
$currencyFormat str_replace($currency'<span style="font-size: 80%;">'.$currency.'</span>'$currencyFormat);
    return 
$currencyFormat
}

osc_add_filter('item_price''cust_resize_currency');
?>


Play with that "font-size: 80%;" until you find a suitable look on every page where price is printed (although this could still be refined to change value depending on page type).

Regards

Regards

Thanks. Works perfect
« Last Edit: May 23, 2015, 02:42:28 pm by Adyyda »

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: FIXED Currency simbol smaller
« Reply #4 on: May 23, 2015, 03:07:41 pm »
 :-X out of bed not the best brain time for me haha :)

Adyyda

  • Sr. Member
  • ****
  • Posts: 435
Re: Currency simbol smaller
« Reply #5 on: May 23, 2015, 05:31:31 pm »
Hi,

There is a filter that may be used for that.

Add this at the very bottom of your theme functions.php (take care not to leave blank lines after this):

Code: [Select]
<?php
function cust_resize_currency($currencyFormat) {
    
$currency preg_replace('~([\d\.,])~u'''$currencyFormat);
    
$currencyFormat str_replace($currency'<span style="font-size: 80%;">'.$currency.'</span>'$currencyFormat);
    return 
$currencyFormat
}

osc_add_filter('item_price''cust_resize_currency');
?>


Play with that "font-size: 80%;" until you find a suitable look on every page where price is printed (although this could still be refined to change value depending on page type).

Regards

I have another question, if posible.

With your code, the currency symbol shows inside the parent <span>. I would like to have it outside like
<span class="value">1234</span>
<span class="symbol">USD</span>
So, can it be done with your code? I am asking this because i would like to truncate just long prices.  Thanks

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: FIXED Currency simbol smaller
« Reply #6 on: May 23, 2015, 06:10:11 pm »
I'm not sure of your currency format, if what you want is something like:

Quote
123.00 Euro

...this variant will do it:

Code: [Select]
<?php
function cust_resize_currency($currencyFormat) {
    
$currency preg_replace('~[^a-zA-Z]~'''$currencyFormat);
    
$currencyFormat str_replace($currency'<span style="font-size: 80%;">'.$currency.'</span>'$currencyFormat);
    return 
$currencyFormat;
}

osc_add_filter('item_price''cust_resize_currency');
?>


Regards

Adyyda

  • Sr. Member
  • ****
  • Posts: 435
Re: FIXED Currency simbol smaller
« Reply #7 on: May 23, 2015, 06:16:15 pm »
Not working, unfortunaly.

<span style="font-size: 80%;">'.$currency.'</span> is still inside the parent <span> - the one with the 674785 value

I would like it to be outside. Like mentioned, if i leave it like this and truncate the lenght. 675867558686 USD will be see as 6758675... (in other words currency is gone).

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: FIXED Currency simbol smaller
« Reply #8 on: May 23, 2015, 06:34:52 pm »
I don't quite understand you... ??? Do you want default single span split into three spans (price|currency_text|currency symbol)?

And please alter this model so I might be able to see it graphically:

Quote
123.00 Euro

Quote my post and modify the code (size=).

Regards
« Last Edit: May 23, 2015, 06:37:53 pm by teseo »

Adyyda

  • Sr. Member
  • ****
  • Posts: 435
Re: FIXED Currency simbol smaller
« Reply #9 on: May 23, 2015, 06:39:40 pm »
Instead of
Code: [Select]
<span class="price">
<span class="currency-value">2.000<span class="currency_symbol"> €</span></span>
</span>

have

Code: [Select]
<span class="price">
<span class="currency-value">2.000</span>
<span class="currency_symbol"> €</span>
</span>

so 2 lines
123.00 on first line
Euro € on a second line

Hope is clear now

Adyyda

  • Sr. Member
  • ****
  • Posts: 435
Re: FIXED Currency simbol smaller
« Reply #10 on: May 23, 2015, 07:26:52 pm »
I have change it via css but noticed one thing. In bender, curreny is missing from the price for premium
http://forums.osclass.org/general-help/(solved)-bug-with-premium-listing-price-in-bender-theme/

I have changed that into
Code: [Select]
<?php if( osc_price_enabled_at_items() ) { ?><span class="currency-value"><?php echo osc_format_price(osc_premium_price()), osc_premium_currency_symbol(); ?></span><?php ?> so that currency is after the price (as it it set in admin) but, this has to be added in your code because it doesn't have any style. Can you adjust it please?

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: FIXED Currency simbol smaller
« Reply #11 on: May 23, 2015, 07:47:46 pm »
Let's see: spans are to keep printing in the same line, if you want two lines you need to use divs:

Code: [Select]
<?php
function cust_resize_currency$currencyFormat) {
    
$currency preg_replace('~[\d\.,]~u'''$currencyFormat);
    
$value preg_replace('~[^\d\.,]~'''$currencyFormat);

    
$currencyFormat '<div class="value">'.$value.'</div>';
    
$currencyFormat .= '<div class="symbol">'.$currency.'</div>';
    return 
$currencyFormat;   
}

osc_add_filter('item_price''cust_resize_currency');
?>


Then you may stylize .value and .symbol to your liking. But take into account that two lines might work well on Ad view but maybe not so well on search lists. You can use osc_is_ad_page() and osc_is_search_page() to adapt the code to each case.

Regards

Adyyda

  • Sr. Member
  • ****
  • Posts: 435
Re: FIXED Currency simbol smaller
« Reply #12 on: May 23, 2015, 07:53:15 pm »
Perfect. I have adapt it to what i want and is perfect. Remains the issue with premium listings as mentioned before.