我想减少我的dom元素
<span class="woocommerce-Price-currencySymbol">TL</span>
价格跨度正在包装
<span class="woocommerce-Price-amount amount">459,00 <span class="woocommerce-Price-currencySymbol">USD</span></span>
所以我不需要它。我想显示价格符号,但不想将其放在跨度内。没必要。
<span class="woocommerce-Price-amount amount">459,00 USD </span>
就足够了。 有任何功能或动作可以做到这一点吗?
答案 0 :(得分:0)
您可以使用 formatted_woocommerce_price 过滤器来实现。
add_filter( 'formatted_woocommerce_price', 'span_custom_prc', 10, 5 );
function span_custom_prc( $number_format, $price, $decimals, $decimal_separator, $thousand_separator)
{
return "<span class='woocommerce-Price-amount amount'>".$number_format." TL</span>";
/* You may use any of these function parameters
* $number_format, $price, $decimals, $decimal_seperator and $thousand_seperator
* To show what exactly you desire inside the span tag.
* Try ".$price.$decimal_seperator.$decimals" instead of $number_format
*/
}
参考:Overriding properly WooCommerce function WC_Price() in a clean way
我希望这会有所帮助。卷边:)