Woocommerce sale flash badge not showing in products page [closed]

the problem that I have is this. I am just helping someone with their woocommerce/wordpress website, I am not very experienced with it but they need some urgent help. Basically, they want to show a badge whenever a product is on sale. I just found the way to do it and it is working fine, but only in the single product page. In the page of a single product, in the related products it shows the badge in the discounted products. But in the general products page it does not show anything. This is the code I got for the single product pages:

function sales_badge( $  text, $  post, $  product ) {         return $  tagType = '<span class="onsale"><img style="max-width: 150px;" src="sale.jpg"></span>'; } add_filter('woocommerce_sale_flash', 'sales_badge', 99, 3 );  

For the theme we are using: Astra and Elementor. I have tried everything and in google but could not find anything related with this. FYI: we are not using any plugin for this and we do not plan to.