Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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