Show discount in percentage - by Spoton marketing

Solved2 replies2 participantsUpdated by Jack Richardson

  • Avatar: Spoton marketing
    Spoton marketing
    Participant

    Hi
    is it possible to display the discount percentage on a product?

    2 Answers

    Avatar: Spoton marketing
    Spoton marketing
    Participant

    fond the answer my self 🙂

    add to function.php

    // Add save percent next to sale item prices.
    add_filter( ‘woocommerce_sale_price_html’, ‘woocommerce_custom_sales_price’, 10, 2 );
    function woocommerce_custom_sales_price( $price, $product ) {
    $percentage = round( ( ( $product->regular_price – $product->sale_price ) / $product->regular_price ) * 100 );
    return $price . sprintf( __(‘ Save %s’, ‘woocommerce’ ), $percentage . ‘%’ );
    }

    Avatar: Jack Richardson
    Jack Richardson
    Support staff

    Hello,

    That’s good to hear!
    Please if you have any questions feel free to contact us.

    Regards,
    Jack Richardson

The issue related to '‘show discount in percentage’' has been successfully resolved, and the topic is now closed for further responses