I’ve got these two snippets from a good source they both work.
But I’m trying to hide strike out only not rrp price. Also I’m trying to prepend rrp and sales price with text. So both rrp and sales price should show, but both be prependeded withncustom text.
add_filter(‘woocommerce_get_price_html’, ‘hide_strikethrough_price’, 100, 2);
function hide_strikethrough_price($price, $product) {
if (is_admin() || !is_shop() && !is_product() && !is_product_category()) {
return $price;
}
if ($product->is_on_sale() && $product->get_regular_price() !== $product->get_price()) {
return wc_price($product->get_sale_price());
}
return $price;
}
if( !function_exists("add_custom_text_prices") ) {
function add_custom_text_prices( $price, $product ) {
// Text
$text_regular_price = __("Non-members: ");
$text_final_price = __("Members only: ");
if ( $product->is_on_sale() ) {
$has_sale_text = array(
'<del>' => '<del>' . $text_regular_price,
'<ins>' => '<br>'.$text_final_price.'<ins>'
);
$return_string = str_replace(
array_keys( $has_sale_text ),
array_values( $has_sale_text ),
$price
);
return $return_string;
}
return $text_regular_price . $price;
}
add_filter( 'woocommerce_get_price_html', 'add_custom_text_prices', 100, 2 );
}