skip to Main Content

I Want to remove span Tags autour the price

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

2

Answers


  1. 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 );
    
    Login or Signup to reply.
  2. 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 }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search