Viewing 10 replies - 1 through 10 (of 10 total)
  • You would need to use a child theme. You would have to either edit the template
    woocommerce/loop/sale-flash.php or add a function in a child theme to filter the woocommerce_sale_flash output.

    Child Theme here: https://www.kadencethemes.com/child-themes/
    Kadence Themes

    Thread Starter kunstudio17

    (@kunstudio17)

    Hey, thanks. I’m in fact using a child theme already.
    Would you be able to indicate the function I should add in it to filter the woocommerce_sale_flash output?

    Thanks in advance

    Are you wanting this to be a set percentage for the whole site? Or are you trying to pull meta content for a product by product percentage?

    The first is easily done, the second is a bit more then what free theme support can write for you.

    Kadence Themes

    Thread Starter kunstudio17

    (@kunstudio17)

    It would be the second, meaning that I want that every product has its own percentage. So I guess it’s not possible here, right?

    Thread Starter kunstudio17

    (@kunstudio17)

    Does the pay version of virtue has this feature?

    Hey,
    It’s not a theme feature. It’s just a customization of some woocommerce functions and output. You would need to add a function that pulls in both prices and figures out the percentage then outputs that percentage into the sale flash. With premium support we often do this for customers just to help.

    Let me think I’ll see if I can quickly come up with something for you in curtesy.

    Kadence Themes

    Thread Starter kunstudio17

    (@kunstudio17)

    Ooh, many thanks!!! It would be wonderful.
    You let me know

    add this function to the functions.php file in your child theme:

    add_filter( 'woocommerce_sale_flash', 'kt_custom_sales_flash', 10, 2 );
    function kt_custom_sales_flash() {
     global $product;
        $percentage = round( ( ( $product->regular_price - $product->sale_price ) / $product->regular_price ) * 100 );
        return '<span class="onsale bg_primary headerfont">'. sprintf( __(' Save %s', 'virtue' ), $percentage . '%' ).'</span>';
    }

    Kadence Themes

    Hello ,

    sorry that i am resurrecting this thread but i have used the function above and i am getting Warning: Division by zero in /functions.php on line 14.

    I have added this function to my functions.php of my child folder of my virtue premium.

    Have i done something wrong?

    Are any of your products free?
    Can you post a link so I know here this is showing?

    Kadence Themes

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Discount Percentage instead of "ON SALE" text in woocommerce’ is closed to new replies.