How to show original strikeout price and sales price even only one variation has discount

This topic has 6 replies, 2 voices, and was last updated 2 months ago ago by Luca Rossi

  • Avatar: kmc
    kmc
    Participant
    October 1, 2025 at 03:23

    Now if a variation product has only one variable option has discount, it doesn’t show strikeout original price and new price, may I know how to show original strikeout price and sales price even only one variation has discount, for both product page and archive page.

    5 Answers
    Avatar: Justin
    Luca Rossi
    Support staff
    October 1, 2025 at 11:17

    Dear @kmc,

    Could you kindly provide some screenshots? We are still not entirely clear about your requests.

    Best regards,
    8Theme Team

    Avatar: kmc
    kmc
    Participant
    October 2, 2025 at 11:06

    Please see attached. You can see from the archive page and product page we cannot see there is actually a discount, unless we select the discounted variation, we can see the strikeout price.

    Please contact administrator
    for this information.
    Files is visible for topic creator and
    support staff only.
    Avatar: Justin
    Luca Rossi
    Support staff
    October 2, 2025 at 17:18

    Hi @kmc,

    Please try adding this custom code under functions.php file locates in your child theme:

    // Display regular price alongside sale price for variable products
    add_filter('woocommerce_variable_sale_price_html', 'custom_variable_sale_price_display', 10, 2);
    add_filter('woocommerce_variable_price_html', 'custom_variable_sale_price_display', 10, 2);
    
    function custom_variable_sale_price_display($price, $product) {
        // Get min and max prices
        $min_regular_price = $product->get_variation_regular_price('min', true);
        $min_sale_price = $product->get_variation_sale_price('min', true);
        $max_regular_price = $product->get_variation_regular_price('max', true);
        $max_sale_price = $product->get_variation_sale_price('max', true);
    
        // Check if product has sale price
        if ($min_sale_price !== $min_regular_price || $max_sale_price !== $max_regular_price) {
            if ($min_sale_price === $max_sale_price && $min_regular_price === $max_regular_price) {
                // Single price (all variations have same price)
                $price = '<del>' . wc_price($min_regular_price) . '</del> <ins>' . wc_price($min_sale_price) . '</ins>';
            } else {
                // Price range - show both regular and sale ranges
                $price = '<del>' . wc_price($min_regular_price) . ' - ' . wc_price($max_regular_price) . '</del> <ins>' . wc_price($min_sale_price) . ' - ' . wc_price($max_sale_price) . '</ins>';
            }
        }
    
        return $price;
    }

    https://prnt.sc/DIZKbO8nW-Bi

    Hope it helps!

    Avatar: kmc
    kmc
    Participant
    October 3, 2025 at 11:47

    Seems still not correct, after I add the code, it only displays one price for the variable product for the archive page and the product page. See attached.

    By right it should still show the original price ranges and strike out, then the discount price range.

    Files is visible for topic creator and
    support staff only.
    Avatar: Justin
    Luca Rossi
    Support staff
    October 3, 2025 at 14:23

    Hi @kmc,

    By default, WooCommerce does not display the original price for variable products.

    If you would like to extend the code provided above, we recommend seeking assistance from tools such as ChatGPT or Claude.AI.

    Please note that custom development falls outside the scope of the standard support services we provide.

    Thank you for your understanding.

    Best regards,
    8Theme’s Team

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

You must be logged in to reply to this topic.Log in/Sign up

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