Product get_sale_price is always 0 when using Discount Rules for WooCommerce plugin

admin

Administrator
Staff member
This is my WordPress configuration (Just upgraded everything, so everything is up to date):<br>
WordPress: 5.4<br>
WooCommerce: 4.0.1<br>
<a href="https://wordpress.org/plugins/woo-discount-rules/" rel="nofollow noreferrer">Discount Rules for WooCommerce</a>: 1.9.7

Discount Rules for WooCommerce configuration, per quantity block:<br>
1-4 : 10%<br>
5-24: 20%<br>
25-99999: 30%

This is working perfectly fine on the shop and shop can even get orders properly with discounts.
The thing is that I want to remove SALE! badge from the products as it is automatically added because of 1-4 quantity block which means default 10% site-wide discount as per the configuration.

Now, here is my code in theme's functions.php

Code:
function wc_custom_replace_sale_text($html, $post, $product) {
  if ($product-&gt;is_on_sale()) {
    $regular_price = $product-&gt;get_regular_price();
    $sale_price = $product-&gt;get_sale_price();
    return '&lt;span class="onsale force-display"&gt;' . $sale_price . '&lt;/span&gt;';
  }
}
add_filter( 'woocommerce_sale_flash', 'wc_custom_replace_sale_text', 10, 3 );

<strong>Problem</strong>: No matter what I try, I always get
Code:
$product-&gt;get_sale_price()
result always 0. And, the strange thing is that
Code:
$product_is_on_sale()
result is
Code:
true
.

Because of this I cannot find out the product discount and so cannot remove SALE label for the 1-4 quantity block.