从Woocommerce价格中删除跨度标签

【从Woocommerce价格中删除跨度标签】我要删除跨度标签使价格自动上涨

< span class="woocommerce-Price-amount amount"> < span class="woocommerce-Price-currencySymbol"> $< /span> 15< /span>

#1在你的活动主题的functions.php中添加以下代码片段-
function modify_wc_price( $return, $price, $args ) { // remove span tags $negative= $price < 0; $formatted_price = ( $negative ? '-' : '' ) . sprintf( $args['price_format'], get_woocommerce_currency_symbol( $args['currency'] ), $price ); return $formatted_price; } add_filter( 'wc_price', 'modify_wc_price', 99, 3 );

#2请使用以下代码, 并在你要使用的标签上更改跨度标签:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); add_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10); function woocommerce_template_single_price() { $price = get_post_meta( get_the_ID(), '_regular_price', true); $price_sale = get_post_meta( get_the_ID(), '_sale_price', true); ?> < del> < span class="woocommerce-Price-amount amount"> < span class="woocommerce-Price-currencySymbol"> $< /span> < ?php echo $price; ?> .00 < /span> < /del> < ins> < span class="woocommerce-Price-amount amount"> < span class="woocommerce-Price-currencySymbol"> $< /span> < ?php echo $price_sale; ?> .00 < /span> < /ins> < ?php }

    推荐阅读