"Display product price in product page when exclude add-on price from apply discount for WooCommerc
Display product price on the product page when excluding add-on price from applied discounts.
add_filter('thwepo_product_price_html', function($display_price_final, $product_id, $price_extra, $price_final){
$price = trim(strip_tags($display_price_final));
$replace_strings = array('$', ' ');
if(function_exists('wc_get_product')){
$product = wc_get_product($product_id);
$original_price = $product->get_price();
$prices = explode(' ', $price);
$price = str_replace($replace_strings, '', $prices[0]);
$price = (float)$price;
if($original_price != $price){
$result = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', $price, $product, 1, 0, 'discounted_price', true, false);
if($result !== false){
$display_price_final = "<del>".wc_price($price_final)."</del><ins>".wc_price($result + $price_extra)."</ins>";
}
}
}
return $display_price_final;
}, 100, 4);