Skip to content

Instantly share code, notes, and snippets.

@KeylorCR
Created June 11, 2019 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KeylorCR/84a25bf0fcb082299f809ea8f133b48c to your computer and use it in GitHub Desktop.
Save KeylorCR/84a25bf0fcb082299f809ea8f133b48c to your computer and use it in GitHub Desktop.
Adding superscript to wc_price filter <sup></sup>. Working to all prices throughout the site.
<?php
/**
** Adding superscript to wc_price <sup></sup>
** not working with prices into select2
**/
function custom_custom_price_format($return, $price, $args, $unformatted_price) {
$elements = explode('.', $price);
if(is_admin()) {
return $return;
} else {
return sprintf( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">%s</span>%s<sup>%s</sup></span>', get_woocommerce_currency_symbol(), $elements[0], $elements[1] );
}
}
add_filter('wc_price', 'custom_custom_price_format', 10, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment