Last active
November 27, 2017 03:52
-
-
Save Bradley-D/1c092a62b9b6475dca49 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Add text before sale price only | |
function bd_sale_price_html( $price, $product ) { | |
if ( $product->is_on_sale() ) : | |
$return_string = str_replace( '<ins>, '<ins><br>Sale Price: ', $price); | |
return $return_string; | |
else : | |
return $price; | |
endif; | |
} | |
add_filter( 'woocommerce_get_price_html', 'bd_sale_price_html', 100, 2 ); |
This file contains hidden or 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
// Add text before regular price and sale price | |
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 ); |
This file contains hidden or 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
// Add text before regualr price only | |
function bd_rrp_price_html( $price, $product ) { | |
$retun_string = 'RRP: ' . $price; | |
return $return_string; | |
} | |
add_filter( 'woocommerce_get_price_html', 'bd_rrp_price_html', 100, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Under the RRP in front of regular price $retun_string should be $return_string. Works great, thanks.