Add Prefix / Suffix to Prices in Single Product Page

Sometimes you may want to add a prefix or a suffix to your prices. It could be something like “From”, “Only”,”tax free” and so on.

You can Simply write the following snippet to your ‘functions.php’.

Add Suffix to WooCommerce Prices:

/**
 * @snippet       Add suffix to WooCommerce prices
 * @author        codeithub.com
  */
   
add_filter( 'woocommerce_get_price_suffix', 'codeithub_add_price_suffix', 99, 4 );
  
function codeithub_add_price_suffix( $html, $product, $price, $qty ){
    $html .= ' suffix here';
    return $html;
}

Add Prefix to WooCommerce Prices:

/**
 * @snippet       Add Prefix to WooCommerce prices
 * @author        codeithub.com
  */
   
add_filter( 'woocommerce_get_price_html', 'codeithub_add_price_prefix', 99, 2 );
  
function codeithub_add_price_prefix( $price, $product ){
    $price = 'Prefix here ' . $price;
    return $price;
}

Before:

See also  Put Cart & Checkout on the Same Page
Single Product Page

After:

suffix and prefix to product Price

Leave a Reply

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