Reputation: 23
I Want to remove span Tags autour the price
<span class="woocommerce-Price-amount amount">
<span class="woocommerce-Price-currencySymbol">$</span>15</span>
Upvotes: 0
Views: 2609
Reputation: 21681
Please use below code and change span tags with your tags, you want to use:
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 }
Upvotes: 0
Reputation: 2768
Add the follows code snippet in your active theme's 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 );
Upvotes: 2