Terry Tsang

Logo - Terry Tsang
About
WooCommerce Show “Free Shipping” Only When It’s Available

WooCommerce Show FREE instead of $0.00

If you didn’t like showing a $0.00 and prefer it with the text “FREE” for the free products.

Below is the code you may copy and paste at the bottom of functions.php where you can access it through > Theme File Editor > functions.php.

add_filter( 'woocommerce_get_price_html', 'tt_product_price_free', 100, 2 );

function tt_product_price_free( $price, $product ) {
    if ( $product->get_price() === ''  || $product->get_price() == 0 ) {
        $price_text = 'FREE'; //you can replace text FREE with any other text
    }

    return $price_text;
}

Check out this Live Demo

Leave a Comment

Your email address will not be published.