Home > OS >  woocommerce automatically adding a word before price
woocommerce automatically adding a word before price

Time:05-17

The prices in my woocommerce store have the words "starting from" automatically added in front of them and I want to remove these words.

This happens on all products both variable and regular products. I need a code that will allow me to completely remove the words that come before the price.

screen shots:

screen shot - regular product

screen shot - variable product

Thanks.

CodePudding user response:

To remove "starting from" prefix from displayed prices, try the following code in function.php file of your active child theme (or active theme).

add_filter( 'woocommerce_get_price_html', 'filter_get_price_html_callback', 10, 2 );
function filter_get_price_html_callback( $price, $product ) {
    return str_replace( __('starting from'), '', $price );
}

Similarly for single product pages:

add_filter( 'woocommerce_get_price_html', 'filter_get_price_html_callback', 10, 2 );
function filter_get_price_html_callback( $price, $product ) {
    if ( is_product() )
        $price = str_replace( __('starting from'), '', $price );

    return $price;
}

Note: Please replace 'starting from' according to your need.

  • Related