Skip to content

Instantly share code, notes, and snippets.

@kabbo508
Created October 15, 2017 17:15
Show Gist options
  • Save kabbo508/366b748f691fe733bde2f6a636467f7c to your computer and use it in GitHub Desktop.
Save kabbo508/366b748f691fe733bde2f6a636467f7c to your computer and use it in GitHub Desktop.
Add text before regular price and sale price at the Woocommerce
function bd_rrp_sale_price_html( $price, $product ) {
if ( $product->is_on_sale() ) :
$has_sale_text = array(
'<del>' => '<del>RRP: ',
'<ins>' => '<br>Sale Price: <ins>'
);
$return_string = str_replace(array_keys( $has_sale_text ), array_values( $has_sale_text ), $price);
else :
$retun_string = 'RRP: ' . $price;
endif;
return $return_string;
}
add_filter( 'woocommerce_get_price_html', 'bd_rrp_sale_price_html', 100, 2 );
@ellebel9
Copy link

ellebel9 commented May 6, 2024

This is exactly what I need, but the code doesn't work (anymore). Could you perhaps update it? Would help me a lot and I would really appreciate it!

RRP: is showing, but Sale Price: isn't.

RRP: is only showing when a product doesn't have a sales price.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment