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

Your email address will not be published. Required fields are marked *

My Agile Privacy
This site uses technical and profiling cookies. You can accept, decline or customize cookies by pressing the desired buttons. By closing this policy you will continue without accepting.

Need help?

Choose one of the following options:

Powered by CodingBunny