0

I want to decrease dom element from my <span class="woocommerce-Price-currencySymbol">TL</span> Price span is wrapping it

<span class="woocommerce-Price-amount amount">459,00&nbsp;<span class="woocommerce-Price-currencySymbol">USD</span></span>

So I don't need it. I want to show price symbol but I don't want to put it inside of a span. It is unnecessary.

<span class="woocommerce-Price-amount amount">459,00&nbsp;USD </span>

is enough. Is there any function or action to do this ?

serdar
  • 454
  • 1
  • 8
  • 26

1 Answers1

1

You can achieve that by using formatted_woocommerce_price filter.

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."&nbsp;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
    */
}

Ref: Overriding properly WooCommerce function WC_Price() in a clean way

I hope this helps. Selamlar :)

MrEbabi
  • 740
  • 5
  • 16
  • Selam :) This code added one more Sybmol. Now I need to remove old symbol with span – serdar Dec 02 '19 at 16:33
  • I am editing my answer to specify the variable I used ($number_format), please check the new answer. If you still have a problem kindly DM me :) – MrEbabi Dec 02 '19 at 16:37