Adds Custom Text after Product Price

Price value is printing on shop, category and single product page via get_price_html() function. get_price_html() is a method of WC_Product_Variable class. In this method have a filter “woocommerce_get_price_html”. You can customize the current price structure with this filter as per your requirement.

In this tutorial I use this filter woocommerce_get_price_html and add the custom text after the product price value. Here is thee PHP snippet.

/**
 * Adds Custom Text after Product Price
 *
 * @copyright 2019 PaulChinmoy.com
 * @author Paul Chinmoy
 */
add_filter( 'woocommerce_get_price_html', 'paulc_add_text_after_price' );
function paulc_add_text_after_price( $price ) {
	$price .= ' ' . __('per Unit', 'woocommerce' ) . '';
    
    return $price;
}

You will add the above PHP snippet in your functions.php file or your custom helper PHP file.

This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.