Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // WooCommerce - show cents within a class so they can be a smaller font
- // Brazilian Reals
- add_filter( 'wc_price', 'my_price', 3, 60 );
- function my_price( $return, $price, $args ) {
- // $return = price with currency symbol
- // $price = price as a number
- // $args = array (inc tax, exc tax)
- $price = str_replace( ',', '.', $price );
- $reals = intval( $price );
- $centavos = ( $price - $reals ) * 100 + 0.0001; // add a little bit for rounding errors
- // ensure $centavos has 2 characters
- $centavos_str = str_pad( $centavos, 2, '0' );
- return 'R$'.$reals.'.<span class="centavos">'.$centavos_str.'</span>';
- }
- // and in custom css:
- .centavos {
- font-size: 70%;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement