Duplicate strikeout and dynamic update fix
Fix duplicate strikeout and dynamic update issues.
add_filter('woo_discount_rules_product_price_container_class', function(){
return ".product-container";
});
function woocommerce_get_price_html_woo_discount_on_sale_compatible($item_price, $product){
$del_pattern = "/<del>(.*?)<\/del>/s";
preg_match($del_pattern, $item_price, $matches);
$del_content = isset($matches[1]) ? $matches[1] : '';
$del_content = trim(strip_tags($del_content));
$ins_pattern = "/<ins>(.*?)<\/ins>/s";
preg_match($ins_pattern, $item_price, $matches);
$ins_content = isset($matches[1]) ? $matches[1] : '';
$ins_content = trim(strip_tags($ins_content));
if(!empty($del_content) && !empty($ins_content)){
$item_price = '<span class="cart_price wdr_product_strikeout">';
$item_price .= $ins_content;
$item_price .= '</span>';
}
return $item_price;
}
add_filter('woocommerce_get_price_html', 'woocommerce_get_price_html_woo_discount_on_sale_compatible', 99, 2);