Fix Pricom theme sale badge issue

Fix sale badge issue in Pricom theme.

if ( ! function_exists( 'pricom_child_product_label' ) ) {
    function pricom_child_product_label() {
        global $product;

        $output = array();
        $product_new = get_post_meta( get_the_ID(), 'haru_product_new', true );
        $product_hot = get_post_meta( get_the_ID(), 'haru_product_hot', true );

        if (is_object($product)) {
            $percentage = '';
            $discount_percentage = apply_filters('advanced_woo_discount_rules_get_product_discount_percentage', 0, $product);
            if ( $discount_percentage > 0 ) {
                $output[] = '<span class="onsale product-label__item product-label__item" style="background: red;">' . sprintf( _x( '-%d%%', 'sale percentage', 'pricom' ), $discount_percentage ) . '</span>';
            } else {
                if ( ! $product->is_in_stock() ) {
                    $output[] = ' <span class="product-label__item product-label__item--onsold">' . esc_html__( 'Sold', 'pricom' ) . '</span>';
                }

                if ( $product_hot == 'yes') {
                    $output[] = '<span class="product-label__item product-label__item--onhot">'. esc_html__( 'Hot', 'pricom' ) . '</span>';
                }

                if ( $product_new == 'yes') {
                    $output[] = ' <span class="product-label__item product-label__item--onnew">' . esc_html__( 'New', 'pricom' ). '</span>';
                } 
            }
        }
        
        if ( $output ) {
            printf( '<span class="product-label__item product-label__item-">%s</span>', implode( '', $output ) );
        }
    }

    add_action( 'after_setup_theme', function() {
        remove_all_filters( 'woocommerce_sale_flash' );
        add_filter( 'woocommerce_sale_flash', 'pricom_child_product_label', 10 );
    });
}