Created
October 15, 2017 17:15
-
-
Save kabbo508/366b748f691fe733bde2f6a636467f7c to your computer and use it in GitHub Desktop.
Add text before regular price and sale price at the Woocommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.