Created
August 29, 2015 11:39
-
-
Save byronrode/26b4fd82f4dc42c038e0 to your computer and use it in GitHub Desktop.
Add <sup></sup> wrapper around decimals for WooCommerce prices.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_get_price_html', 'themeprefix_add_sup_decimals_to_pricing' ); | |
if(!function_exists( 'themeprefix_add_sup_decimals_to_pricing' )){ | |
function themeprefix_add_sup_decimals_to_pricing( $price ) | |
{ | |
if(!is_admin()){ // Check that we're not in the admin | |
$price = strip_tags($price); | |
$price_exploded = explode('–', $price); | |
if(count($price_exploded) > 1) { // Variable Pricing | |
$_price = ''; | |
$count = 0; | |
foreach($price_exploded as $p_e){ | |
$new_pe = explode('.', $p_e); | |
$_price .= '<span class="amount">' . $new_pe[0] . '<sup>.' . $new_pe[1] . '</sup></span>'; | |
if($count < 1) | |
$_price .= '—'; | |
$count++; | |
} | |
return $_price; | |
}else{ // Simple Product Pricing | |
$price_exploded = explode('.', $price); | |
return '<span class="amount">' . $price_exploded[0] . '<sup>.' . $price_exploded[1] . '</sup></span>'; | |
} | |
}else{ | |
return $price; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, how can i change this code so that currency_symbol was not in </ sup>