我要删除跨度标签以自动调整价格
<span class="woocommerce-Price-amount amount">
<span class="woocommerce-Price-currencySymbol">$</span>15</span>
答案 0 :(得分:0)
在活动主题的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 );
答案 1 :(得分:0)
请使用以下代码,并使用您要使用的标签更改跨度标签:
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 }