Show discount in percentage - by Spoton marketing

This topic has 3 replies, 2 voices, and was last updated 10 years, 7 months ago ago by Jack Richardson

  • Avatar: Spoton marketing
    Spoton marketing
    Participant
    May 22, 2014 at 14:36

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

    2 Answers
    Avatar: Spoton marketing
    Spoton marketing
    Participant
    May 22, 2014 at 14:41

    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
    May 22, 2014 at 14:48

    Hello,

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

    Regards,
    Jack Richardson

  • Viewing 3 results - 1 through 3 (of 3 total)

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

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.