Unable to properly show sale badges on single product page and archive

This topic has 13 replies, 3 voices, and was last updated 1 month, 1 week ago ago by Tony Rodriguez

  • Avatar: ziga32
    ziga32
    Participant
    April 19, 2026 at 18:59

    Another store I have the same problem.

    Sale label in settings
    https://cleanshot.com/share/j32Rc4x9

    Shows ok on archive
    https://cleanshot.com/share/ZQmKqqwK

    But not on single product page
    https://cleanshot.com/share/zmlmlGQL

    Tried to translate PRO elements with loco translate but no. What should I do.

    another thing, if I enable to show percentage
    https://cleanshot.com/share/DHjd0qXz

    It does not show on archive
    https://cleanshot.com/share/K7Q2M6f2

    But it show on single product page
    https://cleanshot.com/share/nGwjSXWx

    12 Answers
    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    April 20, 2026 at 08:49

    Hello, ziga32,

    Please provide us with the FTP and admin panel access details for the websites experiencing issues.

    Best regards,
    8Theme Team

    Avatar: ziga32
    ziga32
    Participant
    April 20, 2026 at 09:19

    thank you

    Please contact administrator
    for this information.
    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    April 20, 2026 at 15:40

    Hello, ziga32,

    We have noticed that your website is currently using theme version 9.7, while the latest available version is 9.7.2, which includes fixes for the discount label. May we proceed with updating the theme on your website?

    Best regards,
    8Theme Team

    Avatar: ziga32
    ziga32
    Participant
    April 20, 2026 at 15:56

    sure, sorry, did not know a minor update will fix this.

    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    April 21, 2026 at 08:01

    Hello, ziga32,

    We have updated your theme and plugins. Please check if the issue has been resolved. If not, kindly send us a link to the single product page where the problem occurs.

    Best regards,
    8Theme Team

    Avatar: ziga32
    ziga32
    Participant
    April 21, 2026 at 09:31
    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    April 21, 2026 at 15:58

    Thank you for your clarification. We have added the following code to the functions.php file of your child theme to resolve this issue

    function etheme_sale_label_percentage_text( $product_object, $sale_text, $is_single_product = false ) {
        $element_options = array();
        if ( ! $product_object->is_on_sale() ) {
            return $sale_text;
        }
        $element_options['sale_label_text'] = $sale_text;
        $sale_variables = $is_single_product || etheme_get_option( 'sale_percentage_variable', 0 );
        $product_type = $product_object->get_type();
        if ( $product_type == 'variable' ) {
            if ( $sale_variables ) {
                $element_options['variation_sale_prices'] = array();
                foreach ( $product_object->get_available_variations() as $key ) {
                    if ( $key['display_regular_price'] == $key['display_price'] ) {
                        continue;
                    }
                    $element_options['variation_sale_prices'][] = (float) round( ( ( $key['display_regular_price'] - $key['display_price'] ) / $key['display_regular_price'] ) * 100 );
                }
                if ( count($element_options['variation_sale_prices']) )
                    $element_options['sale_label_text'] = sprintf( esc_html__( 'ZNIŽANO - %s', 'xstore' ), max( $element_options['variation_sale_prices'] ) . '%' );
            }
        } elseif ( $product_type == 'grouped' ) {
            if ( $sale_variables ) {
                $element_options['grouped_sale_prices'] = array();
                foreach ( $product_object->get_children() as $key ) {
                    $_product = wc_get_product( $key );
                    if ( $_product->get_type() == 'variable' && $_product->is_on_sale() ) {
                        foreach ( $_product->get_available_variations() as $key ) {
                            if ( $key['display_regular_price'] == $key['display_price'] ) {
                                continue;
                            }
                            $element_options['grouped_sale_prices'][] = (float) round( ( ( $key['display_regular_price'] - $key['display_price'] ) / $key['display_regular_price'] ) * 100 );
                        }
                    } else {
                        if ( $_product->is_on_sale() ) {
                            $regular_price = (float) $_product->get_regular_price();
                            $sale_price    = (float) $_product->get_sale_price();
                            if ( $regular_price == $sale_price ) {
                                continue;
                            }
                            $element_options['grouped_sale_prices'][] = (float) round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
                        }
                    }
                }
                $element_options['sale_label_text'] = sprintf( esc_html__( 'ZNIŽANO - %s', 'xstore' ), max( $element_options['grouped_sale_prices'] ) . '%' );
            }
    
        } else {
            if ( apply_filters( 'etheme_sale_label_percentage', etheme_get_option( 'sale_percentage', 0 ) ) ){
                if ( $product_type == 'bundle') {
                    $element_options['regular_price']   = (float) $product_object->min_raw_regular_price;
                    $element_options['sale_price']   = (float) $product_object->min_raw_price;
                }
                else {
                    $element_options['regular_price'] = (float) $product_object->get_regular_price();
                    $element_options['sale_price']    = (float) $product_object->get_sale_price();
                }
                if ( $element_options['regular_price'] && $element_options['sale_price'] ) {
                    $element_options['sale_label_text'] = sprintf( str_replace('{sales_text}', $element_options['sale_label_text'], __( '{sales_text} %s', 'xstore' )),round( ( ( $element_options['regular_price'] - $element_options['sale_price'] ) / $element_options['regular_price'] ) * 100 ) . '%' );
                }
            }
        }
        
        if ( class_exists( 'WAD_Discount' ) ) {
            $all_discounts = wad_get_active_discounts( true );
            $product_id    = $product_object->get_id();
            if ( in_array( $product_type, array( 'variation', 'variable' ) ) ) {
                $product_id = $product_object->get_available_variations();
            }
            foreach ( $all_discounts as $discount_type => $discounts ) {
                foreach ( $discounts as $discount_id ) {
                    $discount_obj = new WAD_Discount( $discount_id );
                    if ( $discount_obj->is_applicable( $product_id ) ) {
                        $settings                           = $discount_obj->settings;
                        $element_options['sale_label_text'] = sprintf( esc_html__( 'ZNIŽANO - %s', 'xstore' ),$settings['percentage-or-fixed-amount'] . '%' );
                    }
                }
            }
        }
        
        return $element_options['sale_label_text'];
    }

    Best regards,
    8Theme Team

    Avatar: ziga32
    ziga32
    Participant
    April 21, 2026 at 18:42

    thank you, works great.

    just wondering, should this not be a default way of working or am I missing something?

    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    April 22, 2026 at 09:06

    Hello, ziga32,

    The text field with the percentage is not in a completely standard format – it is a single line. However, to ensure that the percentage works correctly with translations, we had to split this line into two parts; otherwise, the percentages were lost during translation.

    Best regards,
    8Theme Team

    Avatar: ziga32
    ziga32
    Participant
    April 22, 2026 at 10:07

    many thanky, works great!

    Avatar: ziga32
    ziga32
    Participant
    April 22, 2026 at 10:07

    Thanks for the support! My topic “Unable to properly show sale badges on single product page and archive” has been successfully resolved.

    Avatar: Tony Rodriguez
    Tony Rodriguez
    Support staff
    April 22, 2026 at 10:07

    Dear ziga32,

    It’s great having you in our WordPress & WooCommerce community!

    Every insight you share helps us refine XStore and build tools that empower thousands of online store owners worldwide.

    Together, we grow stronger with every release.

    Topic closed.
    The 8Theme Team

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

The issue related to '‘Unable to properly show sale badges on single product page and archive’' 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.