A common WooCommerce request is “How do I add text before the price” or “Can I put text before the price when the product is on sale?”, so I decided to write a plugin to make that easier for people that don’t like getting dirty with code and function files and all that good stuff.

I give you WooCommerce RRP, or you can download it from the WordPress.org repo – WordPress RRP. A simple plugin that allows anyone to add text before the price without the need to write any code or change any template files.

If you don’t want to use my plugin, that’s cool I guess, two ways you can do it:

  1. Write some PHP in your functions file, or
  2. Write some CSS in your style file

Option 1: Add Text Before The Regular And/Or Sale Price With Code

Here are three snippets of code you can use:

  • First example give you the ability to add text before the regular price and sale price. You can change “RRP:” or “Sale Price:” to what you require
  • Second example will allow you to change the text before the “Regular Price” only. You can change “RRP:” to what you require
  • Third example allows you to change the text before the “Sale Price” only. You can change “Sale Price:” to what you require

Add text before regular price and sale price

 

Add text before regular price only

 

 

Add text before sale price only

 

 

Option 2: Use CSS To Add Text Before The Price

 
As all themes are a little different this exact CSS might not work, but hopefully you will get the idea on how you can do it and then apply it to the right selector on your theme. This technique uses the ::before selector that was introduced in CSS2, read all about it here.
 

Add text before the price on a product that is not on sale

 

 

Add text before the sale price (ins) and before the regular price (del)

 

 
And of course if you need to change the content you add for a specific product or category, you can using different CSS selectors, you might find some handy hints at the holy grail for WordPress info – Codex: Post Class

Leave a Reply

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