title: Overriding properly WooCommerce function WC_Price() in a clean way
body: <p>What is the best way to properly override a pre-existing WooCommerce function? In this case I want to modify the <code>wc_price()</code> function. I don't need to do anything crazy with it, I literally just need to add an HTML <code>&lt;span&gt;</code> attribute around the price.</p>
  
  <p>I know the code is as follows: </p>
  
  <pre><code>function wc_price( $price, $args = array() ) {
      extract( apply_filters( 'wc_price_args', wp_parse_args( $args, array(
        'ex_tax_label'       =&gt; false,
        'currency'           =&gt; '',
        'decimal_separator'  =&gt; wc_get_price_decimal_separator(),
        'thousand_separator' =&gt; wc_get_price_thousand_separator(),
        'decimals'           =&gt; wc_get_price_decimals(),
        'price_format'       =&gt; get_woocommerce_price_format(),
      ) ) ) );
  
      $negative        = $price &lt; 0;
      $price           = apply_filters( 'raw_woocommerce_price', floatval( $negative ? $price * -1 : $price ) );
      $price           = apply_filters( 'formatted_woocommerce_price', number_format( $price, $decimals, $decimal_separator, $thousand_separator ), $price, $decimals, $decimal_separator, $thousand_separator );
  
      if ( apply_filters( 'woocommerce_price_trim_zeros', false ) &amp;&amp; $decimals &gt; 0 ) {
         $price = wc_trim_zeros( $price );
      }
  
      $formatted_price = ( $negative ? '-' : '' ) . sprintf( $price_format, '&lt;span class="woocommerce-Price-currencySymbol"&gt;' . get_woocommerce_currency_symbol( $currency ) . '&lt;/span&gt;', $price );
      $return          = '&lt;span class="woocommerce-Price-amount amount"&gt;' . $formatted_price . '&lt;/span&gt;';
  
      if ( $ex_tax_label &amp;&amp; wc_tax_enabled() ) {
         $return .= ' &lt;small class="woocommerce-Price-taxLabel tax_label"&gt;' . WC()-&gt;countries-&gt;ex_tax_or_vat() . '&lt;/small&gt;';
      }
  
      return apply_filters( 'wc_price', $return, $price, $args );
  }
  </code></pre>
  
  <p>All I want to do is to change it to:</p>
  
  <pre><code>function wc_price( $price, $args = array() ) {
      extract( apply_filters( 'wc_price_args', wp_parse_args( $args, array(
        'ex_tax_label'       =&gt; false,
        'currency'           =&gt; '',
        'decimal_separator'  =&gt; wc_get_price_decimal_separator(),
        'thousand_separator' =&gt; wc_get_price_thousand_separator(),
        'decimals'           =&gt; wc_get_price_decimals(),
        'price_format'       =&gt; get_woocommerce_price_format(),
      ) ) ) );
  
      $negative        = $price &lt; 0;
      $price           = apply_filters( 'raw_woocommerce_price', floatval( $negative ? $price * -1 : $price ) );
      $price           = apply_filters( 'formatted_woocommerce_price', number_format( $price, $decimals, $decimal_separator, $thousand_separator ), $price, $decimals, $decimal_separator, $thousand_separator );
  
      if ( apply_filters( 'woocommerce_price_trim_zeros', false ) &amp;&amp; $decimals &gt; 0 ) {
         $price = wc_trim_zeros( $price );
      }
  
      $formatted_price = ( $negative ? '-' : '' ) . sprintf( $price_format, '&lt;span class="woocommerce-Price-currencySymbol"&gt;' . get_woocommerce_currency_symbol( $currency ) . '&lt;/span&gt;', &lt;span class="custom-prc"&gt; . $price . &lt;/span&gt; );
      $return          = '&lt;span class="woocommerce-Price-amount amount"&gt;' . $formatted_price . '&lt;/span&gt;';
  
      if ( $ex_tax_label &amp;&amp; wc_tax_enabled() ) {
         $return .= ' &lt;small class="woocommerce-Price-taxLabel tax_label"&gt;' . WC()-&gt;countries-&gt;ex_tax_or_vat() . '&lt;/small&gt;';
      }
  
      return apply_filters( 'wc_price', $return, $price, $args );
  }
  </code></pre>
  
  <p>Any help at all would be greatly appreciated! Thanks!</p>