Add Prefix and Suffix to Price

Adds a custom prefix and suffix to WooCommerce product prices.

PHP
/**
 * Snippet Name:     Add Prefix and Suffix to Price
 * Snippet Author:   coding-bunny.com
 * Description:      Adds a custom prefix and suffix to WooCommerce product prices.
 * Version:          1.0.0
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

function cbpsp_add_prefix_suffix_to_price( $price, $product ) {
	$prefix = '';
	$suffix = ' incl. VAT';

	$prefix_escaped = esc_html( $prefix );
	$suffix_escaped = esc_html( $suffix );

	return $prefix_escaped . $price . $suffix_escaped;
}
add_filter( 'woocommerce_get_price_html', 'cbpsp_add_prefix_suffix_to_price', 20, 2 );

How To Implement This Solution?

Leave a Reply