我想请你为一个具体的 case 提供帮助.正如我在WooCommercestore 所希望的那样,我能够完全按照我的意愿对价格小数进行风格化.
然而,问题是,现在这个代码也适用于我的WooCommerce checkout 和邮箱.你知道我如何才能使下面的代码不影响WooCommerce checkout 和邮箱页面,并且只影响单一产品和产品档案页面吗?什么是最适合应用的过滤器?
add_filter( 'formatted_woocommerce_price', 'ts_woo_decimal_price', 10, 5 );
function ts_woo_decimal_price( $formatted_price, $price, $decimal_places, $decimal_separator, $thousand_separator ) {
// Not on backend
if ( ! is_admin() ) {
$price_data = explode($decimal_separator, $formatted_price);
return $price_data[0] . '<sup>' . $price_data[1] . '</sup>';
}
return $formatted_price;
}
什么是最适合应用的过滤器?