cancel
Showing results for 
Search instead for 
Did you mean: 

Change price layout all over with own class or style

Change price layout all over with own class or style

Hi,

 

I want to change the price layout all over the site.
I want to change the font-size of the value before comma/point and after comma/point.

even if the currency sign is before or after the value.

(€ 4,00 , £ 4.00, 4,00 €)

So how to make the '4' larger and the '00' smaller


I now use the template: 

app/design/frontend/<mytemplate>/Magento_Catalog/templates/product/price/amount/default.phtml

 

added:

<?php
	$priceproduct = $block->formatCurrency($block->getDisplayValue(), (bool) $block->getIncludeContainer());
if (strpos($priceproduct, ',') !== false) {
	$pricearr = explode(",", $priceproduct);
    $pricesplit = $pricearr[0] . "</span><span class='price-upper'>," . $pricearr[1] ."</span>";
}else if (strpos($priceproduct, '.') !== false) {
    $pricearr = explode(".", $priceproduct);
    $pricesplit = $pricearr[0] . "</span><span class='price-upper'>." . $pricearr[1] ."</span>";
} else {
//     $pricelower = $priceproduct;
    $pricesplit = $priceproduct;
}
?>
....
<!-- ADDED PRICE-->
<?= /* @escapeNotVerified */ $pricesplit; ?>
<!-- END ADDED PRICE-->

It works fine for NL and EN language, but nog for FR.
And also not all over the site, like basket etc. 

 

Is this the right way to do this?

 

 

Eric

 

1 REPLY

Re: Change price layout all over with own class or style

  • You can try to use JS to find all your
    span.price
  • Split strings to array by `.` or `,`
  • Apply your styles to price parts before `.`
Did you find it helpful? Please give "Kudos" or "Accept as Solution".
Meet 70+ extensions and templates for M1 & M2 in one place