Replace the dash by a slash on WooCommerce product prices range

Viewed 514

I would like to replace the dash ( - ) by aslash ( / ) on WooCommerce product price range.

So the displayed price range must be, for example $100 / $200 instead of $100 - $200

Here is a screenshot of what I mean.

Here

1 Answers

Using str_replace() function in woocommerce_format_price_range filter hook, will replace the dash by a slash for WooCommerce product prices range:

add_filter( 'woocommerce_format_price_range', 'custom_format_price_range', 10, 3 );
function custom_format_price_range( $price ) {
    $price = str_replace('–', '/', $price);
    return $price;
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.

Related